DEV Community

Discussion on: Need help understanding: Filtering an array of objects in Javascript

Collapse
 
motss profile image
Rong Sen Ng

Don't use forEach. You're expecting the end result to be an array. Use .map, .filter, or .reduce with to return a new array.