I have two arrays where one is to check the indexes and one is with values to check.
var array = [1200.0, 1000.0, 1000.0, 200.0, 1000.0, 1800.0, 350.0, 336.0, 110.0, 1900.0, 130.0];
var check = [1200.0, 1000.0, 1000.0, 200.0, 110.0, 130.0];
var indeks = [];
for(var i = 0; i < check.length; i++){
// Logger.log(check[i]);
//indeks.push(array.indexOf(check[i]));
function getAllIndexes(arr, val) {
var indexes = [], i = -1;
while ((i = arr.indexOf(val, i+1)) != -1){
indexes.push(i);
}
return indexes;
}
indeks.push(getAllIndexes(array, check[i]));
}
Logger.log(indeks);
the output I am getting now is:
[[0.0], [1.0, 2.0, 4.0], [1.0, 2.0, 4.0], [3.0], [8.0], [10.0]]
I want to get output that looks like this:
[0, 1, 2, 3, 8, 10]
I found getAllIndexes in another question here but somehow it doesn't work well and I am not sure where I am getting wrong.
When I use only indeks.push(array.indexOf(check[i])) I am getting this: [0.0, 1.0, 1.0, 3.0, 8.0, 10.0] which is pretty close to result I am looking for
If anyone know the solution I would be very gratefull