function destroyer(arr) {
// Remove all the values
var aray = [];
aray = arguments;
aray.shift();
arr = arr.filter(function (val){
if(aray.indexOf(val) != -1)
return true;
else
return false;
});
return arr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard.
You’re getting an error because you’re calling shift
on an object that is not an array. You declare the variable aray
as an array, but when you assign it the arguments
object you change that. Check out the MDN article on the arguments object to see how to do what you’re trying to do. You’re very close!
Thanks. Got You. It’s working now.