const sum = (function() {
“use strict”;
return function sum(…z) {
return z.reduce((a, b) => a + b,0);
};
})();
console.log(sum(1,2,3)); // 6
const sum = (function() {
“use strict”;
return function sum(…z) {
return z.reduce((a, b) => a + b,0);
};
})();
console.log(sum(1,2,3)); // 6
What did you find the problem??
Can You describe it very Briefly please
It says that i am not using spread operator on the args parameter.And i am not getting what it means.
The hint I have is to declare the args variable inside the sum (function) instead of below where it is defined as a const…
Hint 2 - it is how you declare the args variable that will give half the solution.
Hint 3 - for full success you need to delete a line that is redundant within the sum function.
Hope that makes some sense!
Well, consider that your function has the z
parameter and not the args
parameter… the tests are really specific on these things