sp2012
1
let myArray = [1, 2, 3];
let arraySum = myArray.reduce((previous, current => previous + current));
console.log(`Sum of array values is: ${arraySum}`);
I get error: Your code should fix the missing piece of the
.reduce()
method. The console output should show that “Sum of array values is: 6”.
Any ideas?
ILM
2
an hint: if I put this in the browser console this error comes up:
VM58:2 Uncaught ReferenceError: previous is not defined
so you probably needs to look around there for your issue. Maybe check what is the syntax for reduce()
sp2012
4
what this means?
previous, current => previous + current
ILM
5
have you tried checking the documentation?
sp2012
6
Thank you for your reply.
sp2012
7
I read the documentation and didn’t figure it out. Can you explain to me, what the following means?
sp2012
9
Thank you for your reply.