DEV Community

Discussion on: can't use .filter() after .forEach()

Collapse
vishnumohanrk profile image
Vishnumohan R K

Use .map()

myArr.map(item => process(item))
  .filter( somelogic )
  .map(item => postProcessSome(item));
Collapse
lionelrowe profile image
lionel-rowe

This won't work unless process(item) returns item.