I'm currently facing an issue with my code - it's supposed to remove all instances of a certain item from an array, but it's not working as expected. Can anyone help me identify what I'm doing wrong?
let nums = [1, 90, 90, 1123, 90, 4534, 90, 90, 90, 90, 90];
function removeAll(array, item) {
for (var i = 0; i < array.length; i++) {
if (array[i] === item) {
array.splice(array.indexOf(item), 1);
}
}
return array;
}
console.log(removeAll(nums, 90));