What’s the difference between .filter() and .map()?

Question

What’s the difference between .filter() and .map()?

Answer

They do different things: .filter() returns a subset of the elements from the original array, while .map() produces an array with new, different entries based on the elements in the original array.