function filter_list(l) {
for (var i = 0; i < l.length; i++) {
if (typeof(l[i]) === 'string') {
l.splice(i, 1);
}
}
return l;
}
console.log(filter_list([1, 2, 'a', 'b']));
When element 2 (index starts with 0) is spliced why doesn't the length of the array in the for loop change to 3? The last element should not be processed but it is processed.