If I have an array similar to this:
var myArray:Array = new Array("a","b","c","d","e","f","g","b");
How can I search it to determine the number of times of value appears in it and in what positions? I found the code below which is close but it will only return the first occurrence.
function findIndexInArray(value:Object, arr:Array):Number {
for (var i:uint=0; i < arr.length; i++) {
if (arr[i]==value) {
return i;
}
}
return NaN;
}
var myArray:Array = new Array("a","b","c","d","e","f","g","b");
trace(findIndexInArray("b", myArray));
// OUTPUT
// 1