I'm trying to make indexOf return me multiple indexes of array's items which value equal "1" (exactly matching).
Here's what I'm doing:
var arr = [1, 11, 1, 111, 1111, 11, 1, 1111, 11];
for (i = 0; i < arr.length; i++){
console.log(arr.findIndex(1, i));
}
Result which I expect is: 0 2 6
But actually I get "-1" value after mentioned indexes. I'm assuming that it's related to array's values (each of them include "1" but not equals to "1"). When I'm doing the same with array of different values, it works as desired.
Does it really related to values? If yes, how to solve this problem? If there are more proper ways to find multiple array's indexes by a value (with exact match), it would be much appreciated.