[javascript] Map and filter an array at the same time