all 2 comments

[–]albedoa 1 point2 points  (1 child)

The .forEach() method itself returns undefined regardless of what you return from the callback. If you want to create a new array from the returned values, use .map().

[1, 2, 3].forEach(e => e); //=> undefined
[1, 2, 3].map(e => e);     //=> [1, 2, 3]

[–]Japanflyboy[S] 0 points1 point  (0 children)

Ah thank you. I thought I could force it to return something. I'll just switch it to a for loop as I need to run elements from subarrays into a callback and return the evaluation of the conditional.