I’m confused. The one test that I cannot get it to pass is:
“The sum function uses the … spread operator on the args parameter.”
I find this confusing. I’ve used the spread operator in both the arg variable and the arguments for the return statement. I have tried putting it other places in the code, but that seems to ruin the whole thing when I do that.
const sum = (() => {
"use strict";
return function sum(...z) {
const args = [ ...z ]
return args.reduce((a, b) => a + b, 0);
};
})();
console.log(sum(1, 2, 3)); // 6
This does clarify the task, but that only goes to show that the task needs adjustment. Line 4 should be removed entirely. It only obfuscates the code changes needed.