Tell us what’s happening:
Im confused on why this isn’t working. I did watch the video and that made more sense to me than the explanation here- as I understand it, the difference would just be that this is a passed function so I think I should be able to write this as:
function renamedFunction(x,y,z){
console.log (x+y+z)
}
var args = [0,1,2,3];
renamedFunction(…args);
Your code so far
const sum = (function() {
"use strict";
return function sum(... z) {
return z.reduce((a, b) => a + b, 0);
};
})();
console.log(sum(1, 2, 3)); // 6
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-the-rest-operator-with-function-parameters/