I want to delete the items which have {"lat":0,"lng":0} in this json object, here's the object :
[{
"lat": 35.77118697154732,
"lng": -5.809084439749561
}, {
"lat": 35.77118697154732,
"lng": -5.809084439749562
}, {
"lat": 0,
"lng": 0
}, {
"lat": 0,
"lng": 0
}, {
"lat": 0,
"lng": 0
}]
I tried this:
storyboard.deleteLngAndLatEqualZeo = function(data) {
for (var i = 0; i < data.length; i++) {
var currentData = data[i];
if (currentData.lat == 0 && currentData.lng == 0) {
data.splice(i, 1);
}
}
console.log(JSON.stringify(data));
}
It doesn't work. Can someone help?
Array.prototype.filterfunctiondata.lenghtis beeing changed inside the loop by usingsplice.