2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
id: a39963a4c10bc8b4d4f06d7e
|
|
|
|
title: Seek and Destroy
|
|
|
|
isRequired: true
|
|
|
|
challengeType: 5
|
|
|
|
videoUrl: ''
|
|
|
|
localeTitle: 寻找和摧毁
|
|
|
|
---
|
|
|
|
|
|
|
|
## Description
|
2020-06-30 01:51:26 -07:00
|
|
|
<section id="description">您将获得一个初始数组(驱逐舰函数中的第一个参数),后跟一个或多个参数。从初始数组中删除与这些参数具有相同值的所有元素。 <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> 。编写自己的代码。 </section>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
## Instructions
|
|
|
|
<section id="instructions">
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
```yml
|
|
|
|
tests:
|
|
|
|
- text: '<code>destroyer([1, 2, 3, 1, 2, 3], 2, 3)</code>应该返回<code>[1, 1]</code> 。'
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert.deepEqual(destroyer([1, 2, 3, 1, 2, 3], 2, 3), [1, 1]);
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: '<code>destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3)</code>应该返回<code>[1, 5, 1]</code> 。'
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert.deepEqual(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3), [1, 5, 1]);
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: '<code>destroyer([3, 5, 1, 2, 2], 2, 3, 5)</code>应该返回<code>[1]</code> 。'
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert.deepEqual(destroyer([3, 5, 1, 2, 2], 2, 3, 5), [1]);
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: '<code>destroyer([2, 3, 2, 3], 2, 3)</code>应该返回<code>[]</code> 。'
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert.deepEqual(destroyer([2, 3, 2, 3], 2, 3), []);
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: '<code>destroyer(["tree", "hamburger", 53], "tree", 53)</code>应该返回<code>["hamburger"]</code> 。'
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert.deepEqual(destroyer(["tree", "hamburger", 53], "tree", 53), ["hamburger"]);
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: '<code>destroyer(["possum", "trollo", 12, "safari", "hotdog", 92, 65, "grandma", "bugati", "trojan", "yacht"], "yacht", "possum", "trollo", "safari", "hotdog", "grandma", "bugati", "trojan")</code>应该返回<code>[12,92,65]</code> 。'
|
2020-02-18 01:40:55 +09:00
|
|
|
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
|
|
|
|
// solution required
|
|
|
|
```
|
|
|
|
</section>
|