Tell us what’s happening:
Is that correct? I got 0 in the console, but the exercise doesn’t accept that solution.
My code so far
const sum = (function() {
"use strict";
return function sum(...args) {
const result = [...args];
const reducer = (acc, props) => acc + props
return result.length === 0 ? "0" : result.reduce(reducer);
};
})();
console.log(sum()); // 0
My browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-the-rest-operator-with-function-parameters/