ES6 - Use the Rest Parameter with Function Parameters

Tell us what’s happening:
Describe your issue in detail here.
Can someone help me in changing this function to an arrow function

  **Your code so far**
let total = 0;
function sum(...inputs) {
for (let i of inputs) {
  total+=i;
}
return total;
}



  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36 Edg/103.0.1264.62

Challenge: ES6 - Use the Rest Parameter with Function Parameters

Link to the challenge:

The starting code has an arrow function. Use it as an example.

Also, you should not be creating global variable (like total). Keep everything inside the function.

I just wanna know how to get loops inside arrow function

The same way you would do it with a non-arrow function, but you first must use arrow function syntax. I put links to previous challenges using arrow functions.

The exact same way as any other function syntax? Can you show what you tried?

in the same way as usual

() => {
for (...) {}
while () {}
do {} while ()
}

it’s there at the beginning

and that’s a loop inside a function, if it doesn’t do what you expect it’s not because it’s a loop

what issues are you having with it?

let total = 0;
function sum(…inputs) {
for (let i of inputs) {
total+=i;
}
return total;
}

Can you make this whole code into an arrow function??

yes, you just need to change the definition to be an arrow function

note that that will not be enough to solve the challenge, for that you will need to follow Randy’s post above

It didn’t look like any sort of arrow function, which is why I asked for your attempts to convert it to an arrow function.