Tell us what’s happening:
i passed the lesson. just wanted to comment on the lack of information provided in the lesson
i only passed because i had previous ES6 experience, and knew how to look through the docs. there should be some mention of the docs or at least the syntax of the rest parameter argument in the lesson.
at least include this snippet from the docs
" A function’s last parameter can be prefixed with ... which will cause all remaining (user supplied) arguments to be placed within a “standard” javascript array. Only the last parameter can be a “rest parameter”. "
Your code so far
const sum = (function() {
"use strict";
return function sum( ...args) {
//const args = [ x, y, z ];
return args.reduce((a, b) => a + b, 0);
};
})();
console.log(sum(1, 2, 3)); // 6
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-the-rest-operator-with-function-parameters