2018-10-04 14:37:37 +01:00
|
|
|
---
|
|
|
|
id: a77dbc43c33f39daa4429b4f
|
|
|
|
title: Boo who
|
|
|
|
challengeType: 5
|
2019-07-31 11:32:23 -07:00
|
|
|
forumTopicId: 16000
|
2018-10-04 14:37:37 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
## Description
|
|
|
|
<section id='description'>
|
|
|
|
Check if a value is classified as a boolean primitive. Return true or false.
|
|
|
|
Boolean primitives are true and false.
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Instructions
|
|
|
|
<section id='instructions'>
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
```yml
|
|
|
|
tests:
|
|
|
|
- text: <code>booWho(true)</code> should return true.
|
2019-07-24 01:47:32 -07:00
|
|
|
testString: assert.strictEqual(booWho(true), true);
|
2018-10-04 14:37:37 +01:00
|
|
|
- text: <code>booWho(false)</code> should return true.
|
2019-07-24 01:47:32 -07:00
|
|
|
testString: assert.strictEqual(booWho(false), true);
|
2018-10-20 21:02:47 +03:00
|
|
|
- text: <code>booWho([1, 2, 3])</code> should return false.
|
2019-07-24 01:47:32 -07:00
|
|
|
testString: assert.strictEqual(booWho([1, 2, 3]), false);
|
2018-10-20 21:02:47 +03:00
|
|
|
- text: <code>booWho([].slice)</code> should return false.
|
2019-07-24 01:47:32 -07:00
|
|
|
testString: assert.strictEqual(booWho([].slice), false);
|
2018-10-04 14:37:37 +01:00
|
|
|
- text: '<code>booWho({ "a": 1 })</code> should return false.'
|
2019-07-27 21:16:04 -07:00
|
|
|
testString: 'assert.strictEqual(booWho({ "a": 1 }), false);'
|
2018-10-04 14:37:37 +01:00
|
|
|
- text: <code>booWho(1)</code> should return false.
|
2019-07-24 01:47:32 -07:00
|
|
|
testString: assert.strictEqual(booWho(1), false);
|
2018-10-04 14:37:37 +01:00
|
|
|
- text: <code>booWho(NaN)</code> should return false.
|
2019-07-24 01:47:32 -07:00
|
|
|
testString: assert.strictEqual(booWho(NaN), false);
|
2018-10-04 14:37:37 +01:00
|
|
|
- text: <code>booWho("a")</code> should return false.
|
2019-07-24 01:47:32 -07:00
|
|
|
testString: assert.strictEqual(booWho("a"), false);
|
2018-10-04 14:37:37 +01:00
|
|
|
- text: <code>booWho("true")</code> should return false.
|
2019-07-24 01:47:32 -07:00
|
|
|
testString: assert.strictEqual(booWho("true"), false);
|
2018-10-04 14:37:37 +01:00
|
|
|
- text: <code>booWho("false")</code> should return false.
|
2019-07-24 01:47:32 -07:00
|
|
|
testString: assert.strictEqual(booWho("false"), false);
|
2018-10-04 14:37:37 +01:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
<div id='js-seed'>
|
|
|
|
|
|
|
|
```js
|
|
|
|
function booWho(bool) {
|
|
|
|
return bool;
|
|
|
|
}
|
|
|
|
|
|
|
|
booWho(null);
|
|
|
|
```
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
function booWho(bool) {
|
|
|
|
return typeof bool === "boolean";
|
|
|
|
}
|
|
|
|
|
|
|
|
booWho(null);
|
|
|
|
```
|
|
|
|
|
|
|
|
</section>
|