2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: a77dbc43c33f39daa4429b4f
|
|
|
|
|
challengeType: 5
|
|
|
|
|
videoUrl: ''
|
|
|
|
|
localeTitle: 嘘谁
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Description
|
2019-12-20 23:20:46 +08:00
|
|
|
|
<section id="description">检查参数是否归类为布尔基元。返回true或false。布尔基元是true和false。如果卡住,请记得使用<a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/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>booWho(true)</code>应该返回true。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.strictEqual(booWho(true), true);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>booWho(false)</code>应该返回true。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.strictEqual(booWho(false), true);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: '<code>booWho([1, 2, 3])</code>应该返回false。'
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.strictEqual(booWho([1, 2, 3]), false);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: '<code>booWho([].slice)</code>应该返回false。'
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.strictEqual(booWho([].slice), false);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: '<code>booWho({ "a": 1 })</code>应该返回false。'
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: 'assert.strictEqual(booWho({ "a": 1 }), false);'
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>booWho(1)</code>应该返回false。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.strictEqual(booWho(1), false);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>booWho(NaN)</code>应该返回false。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.strictEqual(booWho(NaN), false);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>booWho("a")</code>应该返回false。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.strictEqual(booWho("a"), false);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>booWho("true")</code>应该返回false。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.strictEqual(booWho("true"), false);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>booWho("false")</code>应该返回false。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.strictEqual(booWho("false"), false);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
|
|
<div id='js-seed'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
function booWho(bool) {
|
|
|
|
|
// What is the new fad diet for ghost developers? The Boolean.
|
|
|
|
|
return bool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
booWho(null);
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
|
|
```js
|
2019-12-20 23:20:46 +08:00
|
|
|
|
function booWho(bool) {
|
|
|
|
|
return typeof bool === "boolean";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
booWho(null);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```
|
2020-08-13 17:24:35 +02:00
|
|
|
|
|
|
|
|
|
/section>
|