Currently I'm making my way through TOP. I am on the removeFromArray problem, and I'm running into one issue I can't figure out.
When I input:
removeFromArray([1, 2, 3, 4], 2, 3);
the function returns [1, 4], as it should, but when I reverse that to
removeFromArray([1, 2, 3, 4], 3, 2);
the function returns [1, 3, 4]
Compared to the solution TOP has listed, it's definitely not optimized, but I'd love to learn why this method isn't working before moving on. Here is the code for the function.
const removeFromArray = function(array, ...args) {
for (let i = 0; i < array.length; i ++) {
for (let j = 0; j < args.length ; j++){
if (array[i] === args[j]) {
array.splice(i, 1);
}
}
}
return array;
};