Catch Unclosed Parentheses, Brackets, Braces and Quotes

Catch Unclosed Parentheses, Brackets, Braces and Quotes
0.0 0

#1

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


#2

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:


#3

Oh it was just one parenthesis. thanks man!!


#4

Check out that arrow function it may be missing something…


#5

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}`);

#6

@bluebird008 You are missing one ( and one ).

Hint: The reduce function should be wrapped in ( ) and yours is not and also, if you are using specifying more than one argument for the reduce callback function, you must surround all of the with ( ).


#7

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 ?


#8

You correct the first part of what I suggested (reduce function should be wrapped in ( ). However, you still have not surround the arguments of the callback function completely. You added the ) I mentioned in the wrong place.


#9

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}`);