Skip to content

Instantly share code, notes, and snippets.

@410063005
Created November 22, 2019 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 410063005/a1ef98ab0762ad124ad42938694356c0 to your computer and use it in GitHub Desktop.
Save 410063005/a1ef98ab0762ad124ad42938694356c0 to your computer and use it in GitHub Desktop.
摧毁数组 金克斯的迫击炮!
// https://www.freecodecamp.cn/challenges/seek-and-destroy
function destroyer(arr) {
// 请把你的代码写在这里
var argLen = arguments.length;
if (argLen > 1) {
var args = Array.from(arguments);
var c = args.slice(1);
return arr.filter(function(v) {
var found = false;
for (var i = 0; i < c.length; i++) {
found = found || (v == c[i]);
}
var keep = !found;
console.log(v + " = " + keep);
return keep;
});
}
return arr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment