Created
November 22, 2019 06:55
-
-
Save 410063005/a1ef98ab0762ad124ad42938694356c0 to your computer and use it in GitHub Desktop.
摧毁数组 金克斯的迫击炮!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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