Catch Unclosed Parentheses, Brackets, Braces and Quotes

Tell us what’s happening:

Your code so far


let myArray = [1, 2, 3];
let arraySum = myArray.reduce((previous, current =>  previous + current));
console.log(`Sum of array values is: ${arraySum}`);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/debugging/catch-unclosed-parentheses-brackets-braces-and-quotes

1 Like

You still have syntax errors in your reduce function.

Here is the syntax of an arrow function :

const myArrowFunc = (x, y) => {
  // things
  return x + y;
}

So basically, you forgot one parenthesis and some curly braces :wink:

2 Likes

Oh it was just one parenthesis. thanks man!!

Check out that arrow function it may be missing something…

Hello Guys , I did like this , but it’s not going through

let myArray = [1, 2, 3];
let arraySum = myArray.reduce(previous, current) =>  {
return previous + current;
}
console.log(`Sum of array values is: ${arraySum}`);

Yes , that brings like that

let myArray = [1, 2, 3];
let arraySum = myArray.reduce((previous, current =>  previous + current));
console.log(`Sum of array values is: ${arraySum}`);

Now what ?

1 Like

Got It Finally. thank you

let myArray = [1, 2, 3];
let arraySum = myArray.reduce((previous, current) =>  previous + current);
console.log(`Sum of array values is: ${arraySum}`);
1 Like

It will work
let arraySum = myArray.reduce((previous, current )=> ( previous + current));