My array looks like this:
var my_array=[
[[1,0], [2,2], [4,1]],
[[4,9], [3,1], [4,2]],
[[5,6], [1,5], [9,0]]
]
I'd like to filter the my_array above and remove all arrays (e.g. [[4,9], [3,1], [4,2]]) from the array above IF all child arrays of the array have no specific value (e.g. 0) at the 1. position (child array[1])
So my result should look like this:
var result_array=[
[[1,0], [2,0], [4,1]],
[[5,6], [1,5], [9,0]]
]
See above: Remove second array from
my_arraybecause the second child arrays do not include a0-column at the first index.
My idea was to use something like this code, but I can not really get it working:
var my_array=[
[[1,0], [2,2], [4,1]],
[[4,9], [3,1], [4,2]],
[[5,6], [1,5], [9,0]]
]
result_array = my_array.filter(function(item){ return item[1] != 0 })
console.log(JSON.stringify(result_array))
[4,9]this one!