I'm trying to remove all the numbers from an array. The loop works exactly as I want, but the splice() method still skips some elements for some reason.
let arr = ['1', '2', '3', '4', '5', 'notanumber', '6'];
for (let element of arr) {
let index = arr.indexOf(element);
let check = isNaN(element);
if (check === false) {
arr.splice(index, 1);
};
};
console.log(arr);
Expected output is: ['notanumber']
Current output is: ['2', '4', 'notanumber']