I have an array rosters
and i want to alter this array according to some conditions. Here what I'm trying to do.
somefunction(callback) {
for (var i in this.rosters) {
var roster = this.rosters[i];
if (roster.age > 7200) {
this.rosters.splice(i, 1);
} else {
this.rosters[i].age = this.EMarshal.tu.getAgeOfTime(
this.EMarshal.tu.getMyTime(
this.EMarshal.tu.getMyDate(roster.date), roster.shifttime
)
);
console.log(this.rosters[i].age);
}
}
callback();
}
When the the if
condition is true and splice
is been called, control comes out of from loop and call callback()
. But i want to run the loop for each values in the array.
plz carefully notice that there are rosters
and roster
2 different variables.
Any idea why its happening and the solution will be usefull. Thanks