Hello, Please am having issues passing this challenge on Rest Operator!
i have tried editing the code but it still doesn’t pass.
i keep getting this error message: The sum function uses the … spread operator on the args parameter..
this is my code so far:
const sum = (function() {
"use strict";
return function sum(...arg) {
// const args = [ x, y, z ];
return arg.reduce((a, b) => a + b, 0);
};
})();
console.log(sum(1, 2, 3));
AND
function sum(...arg){
let args = arg.reduce((a,b)=>a+b, 0);
return args
}
console.log(sum(1,2,3,));