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