2018-10-10 18:03:03 -04:00
---
id: a39963a4c10bc8b4d4f06d7e
title: Seek and Destroy
isRequired: true
challengeType: 5
2019-08-28 16:26:13 +03:00
forumTopicId: 16046
2018-10-10 18:03:03 -04:00
localeTitle: Найти и уничтожить
---
## Description
2019-08-28 16:26:13 +03:00
< section id = 'description' >
2020-06-30 01:51:26 -07:00
Вам будет предоставлен исходный массив (первый аргумент в функции эсминца), за которым следуют один или несколько аргументов. Удалите все элементы из исходного массива, которые имеют такое же значение, что и эти аргументы. < strong > Заметка< / strong > < br > Вы должны использовать объект < code > arguments< / code > . Н е забудьте использовать < a href = "https://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck-coding/19514" target = "_blank" > Read-Search-Ask,< / a > если вы застряли. Напишите свой собственный код.
2019-08-28 16:26:13 +03:00
< / section >
2018-10-10 18:03:03 -04:00
## Instructions
2019-08-28 16:26:13 +03:00
< section id = 'instructions' >
2018-10-10 18:03:03 -04:00
< / section >
## Tests
< section id = 'tests' >
```yml
tests:
2019-08-28 16:26:13 +03:00
- text: < code > destroyer([1, 2, 3, 1, 2, 3], 2, 3)</ code > should return < code > [1, 1]</ code > .
testString: assert.deepEqual(destroyer([1, 2, 3, 1, 2, 3], 2, 3), [1, 1]);
- text: < code > destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3)</ code > should return < code > [1, 5, 1]</ code > .
testString: assert.deepEqual(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3), [1, 5, 1]);
- text: < code > destroyer([3, 5, 1, 2, 2], 2, 3, 5)</ code > should return < code > [1]</ code > .
testString: assert.deepEqual(destroyer([3, 5, 1, 2, 2], 2, 3, 5), [1]);
- text: < code > destroyer([2, 3, 2, 3], 2, 3)</ code > should return < code > []</ code > .
testString: assert.deepEqual(destroyer([2, 3, 2, 3], 2, 3), []);
- text: < code > destroyer(["tree", "hamburger", 53], "tree", 53)</ code > should return < code > ["hamburger"]</ code > .
testString: assert.deepEqual(destroyer(["tree", "hamburger", 53], "tree", 53), ["hamburger"]);
- text: < code > destroyer(["possum", "trollo", 12, "safari", "hotdog", 92, 65, "grandma", "bugati", "trojan", "yacht"], "yacht", "possum", "trollo", "safari", "hotdog", "grandma", "bugati", "trojan")</ code > should return < code > [12,92,65]</ code > .
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]);
2018-10-10 18:03:03 -04:00
```
< / section >
## Challenge Seed
< section id = 'challengeSeed' >
< div id = 'js-seed' >
```js
function destroyer(arr) {
// Remove all the values
return arr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
```
< / div >
< / section >
## Solution
< section id = 'solution' >
```js
2019-08-28 16:26:13 +03:00
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);
2018-10-10 18:03:03 -04:00
```
2019-08-28 16:26:13 +03:00
2018-10-10 18:03:03 -04:00
< / section >