I am trying to delete all even numbers from the array but it just doesnt delete all of them . not sure why
var arr = [3,45,56,7,88,56,34,345];
for (var i = 0; i < arr.length; i++) {
if (arr[i] % 2 === 0) {
arr.splice(i,1);
}
}
console.log(arr); gives this - [3, 45, 7, 56, 345] instead of this [3, 45, 7, 345]
Any ideas?
for-loop through arrayproblem.