Tell us what’s happening:
While running the below code I am getting " The sum
function uses the ...
spread operator on the args
parameter." error. Can you explain why?
Your code so far
const sum = (function() {
"use strict";
return function sum(...x) {
return x.reduce((a, b) => a + b, 0);
};
})();
console.log(sum(1, 2, 3)); // 6
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
.