--- id: a39963a4c10bc8b4d4f06d7e title: Seek and Destroy localeTitle: Buscar y destruir isRequired: true challengeType: 5 --- ## Description
Se le proporcionará una matriz inicial (el primer argumento en la función del destructor), seguido de uno o más argumentos. Elimine todos los elementos de la matriz inicial que tengan el mismo valor que estos argumentos. Nota
Tienes que usar el objeto arguments . Recuerda usar Read-Search-Ask si te atascas. Escribe tu propio código.
## Instructions
## Tests
```yml tests: - text: ' destroyer([1, 2, 3, 1, 2, 3], 2, 3) debe devolver [1, 1] .' testString: 'assert.deepEqual(destroyer([1, 2, 3, 1, 2, 3], 2, 3), [1, 1], "destroyer([1, 2, 3, 1, 2, 3], 2, 3) should return [1, 1].");' - text: ' destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3) debe devolver [1, 5, 1] .' testString: 'assert.deepEqual(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3), [1, 5, 1], "destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3) should return [1, 5, 1].");' - text: ' destroyer([3, 5, 1, 2, 2], 2, 3, 5) debe devolver [1] .' testString: 'assert.deepEqual(destroyer([3, 5, 1, 2, 2], 2, 3, 5), [1], "destroyer([3, 5, 1, 2, 2], 2, 3, 5) should return [1].");' - text: ' destroyer([2, 3, 2, 3], 2, 3) debe devolver [] .' testString: 'assert.deepEqual(destroyer([2, 3, 2, 3], 2, 3), [], "destroyer([2, 3, 2, 3], 2, 3) should return [].");' - text: ' destroyer(["tree", "hamburger", 53], "tree", 53) debe devolver ["hamburger"] .' testString: 'assert.deepEqual(destroyer(["tree", "hamburger", 53], "tree", 53), ["hamburger"], "destroyer(["tree", "hamburger", 53], "tree", 53) should return ["hamburger"].");' - text: ' destroyer(["possum", "trollo", 12, "safari", "hotdog", 92, 65, "grandma", "bugati", "trojan", "yacht"], "yacht", "possum", "trollo", "safari", "hotdog", "grandma", "bugati", "trojan") debe devolver [12,92,65] . ' testString: 'assert.deepEqual(destroyer(["possum", "trollo", 12, "safari", "hotdog", 92, 65, "grandma", "bugati", "trojan", "yacht"], "yacht", "possum", "trollo", "safari", "hotdog", "grandma", "bugati", "trojan"), [12,92,65], "destroyer(["possum", "trollo", 12, "safari", "hotdog", 92, 65, "grandma", "bugati", "trojan", "yacht"], "yacht", "possum", "trollo", "safari", "hotdog", "grandma", "bugati", "trojan") should return [12,92,65].");' ```
## Challenge Seed
```js function destroyer(arr) { // Remove all the values return arr; } destroyer([1, 2, 3, 1, 2, 3], 2, 3); ```
## Solution
```js function destroyer(arr) { var hash = Object.create(null); [].slice.call(arguments, 1).forEach(function(e) { hash[e] = true; }); // Remove all the values return arr.filter(function(e) { return !(e in hash);}); } destroyer([1, 2, 3, 1, 2, 3], 2, 3); ```