I have an of object, contains 5 element.
Now I loop through the to delete elements of which match with my condition.
for(var i = 0; i < items.length ; i++){
console.log(i + '-'); //the result is 3-4
if(_today.getTime() - items[i].timestamp >= numDay * ONE_DAY){
console.log(i); //the result is 3
items.splice(i,1);
}
}
Sample of my array :
[{"DepartmentID":56,"CategoryID":117,"BrandID":19,"ID":707},
{"DepartmentID":56,"CategoryID":117,"BrandID":19,"ID":708},
{"DepartmentID":56,"CategoryID":117,"BrandID":19,"ID":709},
{"DepartmentID":56,"CategoryID":117,"BrandID":19,"ID":710},
{"DepartmentID":56,"CategoryID":117,"BrandID":19,"ID":711}]
The delete only one element in this for loop.
Is it because of the index of problem and how could I delete n elements of the that match the condition in this loop?
Any help would be much appreciated, thank you..