DEV Community

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

Collapse
 
vishnumohanrk profile image
Vishnu

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.