const operations = {
add: (a, b) => a + b,
subtract: (a, b) => a - b,
multiply: (a, b) => a * b,
divide: (a, b) => b !== 0 ? a / b : null,
};
const pipeline = (...fns) => (value) => fns.reduce((acc, fn) => fn(acc), value);
const double = (x) => operations.multiply(x, 2);
const addTen = (x) => operations.add(x, 10);
const halve = (x) => operations.divide(x, 2);
const subtractThree = (x) => operations.subtract(x, 3);
const transform = pipeline(double, addTen, halve, subtractThree);
console.log(transform(5));
Ответ: 7
JavaScript test | #JavaScript & Max