How can I return items that match a condition? [duplicate]

I'm using map which returns me html elements:

const activeStep = 1;

{filteredData.map((el) => (
  <MarketItem el={el} />
))}

But how I can made some condition, which returns me the same elements which is responding to condition.

So , when activeStep === 1 , I need to return only elements from filteredData which have the key and value like this el.isSelected === true, in other case if activeStep !== 1 I need to return all elements from filteredData even el.isSelected !== true



Read more here: https://stackoverflow.com/questions/64890772/how-can-i-return-items-that-match-a-condition

Content Attribution

This content was originally published by Vlad Movchan at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: