To find index of all occurrences of element in array, we use the
For instance, we write
const nanoIndexes = cars .map((car, i) => (car === "Nano" ? i : -1)) .filter((index) => index !== -1);
map with a callback that checks if the
car value being iterated through is
If it is, we return
i and we return -1 otherwise.
Then we call
filter with a callback that returns an array with the
index value not equal to -1.