DEV Community

Discussion on: Why this regex it's not working properly? [solved]

Collapse
frondor profile image
Federico Vázquez

Or better yet, a pure function:

const knownFruits = new Set(["apple", "banana", "watermelon"])

function getFruits(foodList) {
  return foodList.filter(food => knownFruits.has(food))
}
Enter fullscreen mode Exit fullscreen mode