I need to filter an array, so I've this code that works for a normal array
var arr = [138,124,128,126,140,113,102,128,136,110,134,132,130,132,132,104,116,135,120];
var limit = 112;
var lowarray = arr.filter(function(x) {
return x <= limit;
});
var higharray = arr.filter(function(x) {
return x > limit;
});
console.log(lowarray);
console.log('');
console.log(higharray);
The problem is that I've to apply it to a 2d array but I tried and no results!
for example I've this array
var arr [[1,5],[2,4],[3,6],[4,2],[5,2]];
I wanna split it with the same idea
var limit = 3;
so the lowarray would be
[[1,5],[2,4],[3,6]];
and the higharray would be
[[4,2],[5,2]];
Any Idea?