Tell us what’s happening:
Describe your issue in detail here.
I’m having trouble grasping this rest parameter concept and why it isn’t working for me. I’m confused because the instructions say to , " Modify the function sum
using the rest parameter in such a way that the function sum
is able to take any number of arguments and return their sum". But the error message says " sum should be an arrow function which uses the rest parameter syntax on the args parameter" I’ve tried using the rest paremeter syntax on sum function and tried it on the args variable and nothing worked. What am I missing? I’ve tried referencing MDN and Eloquent JS book and nothing is helping understand why this isn’t working for me.
**Your code so far**
const sum = (...x,) => {
const args = [x, y, z];
return args.reduce((a, b) => a + b, 0);
}
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36
Challenge: Use the Rest Parameter with Function Parameters
Link to the challenge: