I have this code, and all I'm tryin' to do is delete values from the original arr
array which are not numbers to output a revised array with number values only.
For some reason, it manages to weed out through certain values but not the others (check the console output below. The debugger didn't shed much light on this behaviour - could someone please help?
const arr = [3, 9, NaN, false, 13, -10, false, 17, 14, 9, 5, true, "error", true, false, "error", false];
for (let i = 0; i < arr.length; i++) {
if (typeof arr[i] !== "number" || isNaN(arr[i]))
arr.splice(i, 1);
}
console.log(arr);