Xhitiz
June 4, 2018, 9:01am
#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
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
2 Likes
Xhitiz
June 4, 2018, 9:10am
#3
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}`);
@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 ( ).
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 ?
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.
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}`);
It will work
let arraySum = myArray.reduce((previous, current )=> ( previous + current));