Web 101 removeFromArray.js criticism wanted


My solution to pass the tests can be seen below, looking for some constructive criticism, should I attempt to find a better solution or will this one suffice for the time being. It is good in that I don’t need to overload the function mutiple times but n² complexity.

var removeFromArray = function(array, ...values) {
        for (j = 0; j<values.length;j++){
            if(array[i] === values[j]) array.splice(i,1);
    return array;


The preferred solution would be to use filter on the array to filter out any values to be removed.

One thing you can do in your solution is once you have a match if(array[i] === values[j]) you can break out of that inner for loop. That would slightly reduce the complexity in some circumstances but not in a worst case scenario.