Why does, "return", not work here?

Hi all,

I was just curious to know why, “return”, wont work here but, “console.log(value)”, works?


let numbers = [1,2,3,4,5,6];

let returnNumbers = numbers.forEach(value => {
return value;



The return value of forEach is undefined;
You cannot return a sum for instance with forEach.

Let imagine it would return value, it would crush that value for every new value processed and actually display the last one I believe.

Here are 2 options to return a sum for example:

let numbers = [1,2,3,4,5,6,7,8,9];

let returnNumbers = 0;
numbers.forEach(v => {
	returnNumbers += v;

let result = numbers.reduce((a,b) => a+b);

console.log(result); // 45
console.log(returnNumbers); // 45


1 Like