Write a JavaScript program to perform left-to-right function composition
- برمجة جافاسكربت java script
- برمجة
- 2021-06-03
- ahmadghneem
الأجوبة
const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
const add5 = x => x + 5;
const multiply = (x, y) => x * y;
const multiplyAndAdd5 = pipeFunctions(multiply, add5);
console.log(multiplyAndAdd5(5, 2));
console.log(multiplyAndAdd5(16, 2));
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال