Intermediate Algorithm Scripting: Seek and Destroy

Intermediate Algorithm Scripting: Seek and Destroy
0.0 0

#1

This is my code witch doesn’t for some reason:
function destroyer(arr) {
let test = Array.from(arguments[0]);
let args = Array.from(arguments).slice(1);
return test.filter(function(cur) {
return !args.includes(cur);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

On the other hand this correct solution:
function destroyer(arr) {
var args = Array.from(arguments).slice(1);
return arr.filter(function(val) {
return !args.includes(val);
});
}
I would like to know why my code doesn’t work.Am I doing something wrong with arguments?


#2

Well, you have syntax errors.

return test.filter(function(cur) {
    return !args.includes(cur);
}
// missing ) for filter()
// missing } to close destroyer()