What is the problem with this? It does not print.
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/debugging/catch-unclosed-parentheses-brackets-braces-and-quotes
let myArray = [1, 2, 3];
let arraySum = (previous, current) => previous + current;
let result = console.log(myArray.reduce(arraySum));
let a = "Sum of array values is";
console.log(result);
let result = console.log(myArray.reduce(arraySum));
You don’t want to assign a console.log
to a variable.
1 Like
I want the result in the same line; what may I do?
let myArray = [1, 2, 3];
let arraySum = (previous, current) => previous + current;
console.log("Sum of array values is: " );
let a = console.log(myArray.reduce(arraySum));
it is done.
let myArray = [1, 2, 3];
let arraySum = myArray.reduce(myArray=> 1+2+3);
console.log(`Sum of array values is: ${arraySum}`);