Tell us what’s happening:
Whats wrong with my code??? it gives me this error:
“The sum function uses the … spread operator on the args parameter.”
My code so far
const sum = (function() {
"use strict";
return function sum(...a) {
return a.reduce((a, b) => a + b, 0);
};
})();
console.log(sum(1, 2, 3)); // 6
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-the-rest-operator-with-function-parameters