REST OPERATOR Test not passing

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,));

Please need some suggestions/help

This should be args and not arg.

Same thing over here as well.
This should do it.

still throwing same error to me: The function sum uses the …spread bla bla bla
how did you pass yours? @aditya_p

Could you post your latest code?
Cause changing the arg to args in your code passes the tests for me.

ok… @aditya_p

const sum = (function() {
  "use strict";
  return function sum(...arg) {
    const args = [...arg];
    return args.reduce((a, b) => a + b, 0);
  };
})();
console.log(sum(1, 2, 3,)); // 6

You don’t need to use these.
Just change this

to ...args.
Instruction clearly says:

The sum function uses the ... spread operator on the args parameter.

Does this help?

thanks…
it worked!!

1 Like