Q:

Write a JavaScript program to create a function that invokes the provided function with its arguments transformed

0

Write a JavaScript program to create a function that invokes the provided function with its arguments transformed.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val)));
const square = n => n * n;
const double = n => n * 2;
const fn = overArgs((x, y) => [x, y], [square, double]);
console.log(fn(9,3));
console.log(fn(5,2));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now