DEV Community

Discussion on: The moment I realized forEach() does not return anything.

Collapse
 
iaboelsuod profile image
Ibrahim Zahema

I was thinking why foreach ALWAYS returns undefined by design. But in your use case it would have been better to use find & return whatever it returns. It can be chained and will break once the element is found.