Write a JavaScript program to perform left-to-right function composition

  • برمجة جافاسكربت java script
  • برمجة

Write a JavaScript program to perform left-to-right function composition

الأجوبة

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));
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...