You have to write the reduce as a function call. What you’re looking for is:
let arraySum = myArray.reduce((previous, current) => previous + current);
Notice that the two parameters previous and current are enclosed in parenthesis because they are parameters of the function. Since you’re going to use this as an arrow function, you put => to indicate there is going to be a command following and then it is implied to return previous + current.
You could rewrite that function with the function keyword, too:
Thank you for your beautiful explanation. However, as beautifully presented as it is, there is still a little confusion. First, to my understand, in human English, this whole thing is read thus: let arraySum = myArray.(.=multiply)reduce((previous, current) =>(I don’t know how to read/interpret this equal(=)behind arrow head (>) thing) previous + current);
Yeah, what does this equal sign behind arrow head (=>) mean??? How do I read it?
What’s in quotes (“”)? There is no quotation sign in the text, so you kind of confuse me a bit when you mentioned it. I only see parenthesis; what quotes are you talking about?
Then, let’s talk about the “arrow function.” Pray tell, what is an “arrow function?”
let arraySum = myArray.reduce((previous, current) => previous + current);
Thank you very much for your help in teaching me the rope of understanding this alien( ) language.
Oops I did mean to say parenthesis, not quotes. But you should really retake the earlier courses. I think you’d benefit greatly from that. Arrow functions are covered in the ES6 section of the course.