+ 1
Please help with this code coach
function Add(input){ let num = 0; for (let i of input){ num += i; } return num; } console.log(Add(1,2,3)); console.log(Add(4,14,5,9,14)); console.log(Add(2,36)); Whats wrong?!
5 Answers
+ 1
Is that solution given by Sololearn? Where? Can you add details..
+ 2
You are passing multiple values but function has a single variable of primitive type.
Change function parameter to as array (...input)
Or pass values as an array by using [ ] braces like :
console.log(Add( [1,2,3] ))
0
Ah, thanks
0
So the solution of the sololearn code coach is wrong?
0
Yes the solution given in âRest and Spreadâ lesson in EcmaScript 6. The solution is wrong. Look at it.