Tell us what’s happening:
Why is the result different of these two cases:
function destroyer(arr) {
var a = arguments;
var newArr = ;
for (var i = 1; i < arguments.length; i++){
newArr = arr.filter(function(val){
return val != arguments[i];
});
return newArr;
}
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
VS
function destroyer(arr) {
// Remove all the values
var a = arguments;
// var length = a.length;
var newArr = ;
for (var i = 1; i < arguments.length; i++){
newArr = arr.filter(function(val){
return val != a[i];
});
return newArr;
}
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Your code so far
function destroyer(arr) {
// Remove all the values
var a = arguments;
// var length = a.length;
var newArr = [];
for (var i = 1; i < arguments.length; i++){
newArr = arr.filter(function(val){
return val != arguments[i];
});
return newArr;
}
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/seek-and-destroy