I can't actually find a solution after browsing the internet and making some tests. I'm trying to find the indexes of where there are most 0s together. For example, this should return 3 and 6:
var arr1 = [1,0,1,0,0,1,0,0,1,1];
var joined1 = arr1.join(''); // "1010010011"
var ans = joined1.indexOf("00"); // returns 3 - want to return 3 & 6
And this should return 1 and 5:
var arr2 = [1,0,0,0,1,0,0,0,1,0,0,1,1];
var joined2 = arr2.join(''); // "10001000100111"
var ans2 = joined2.indexOf("000"); // returns 1 - want to return 1 & 5
The problem is that indexOf only returns the first index rather than both. How can I get it to return all instances where the condition is satisfied? thanks for any help