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
|
2021-01-13 03:31:00 +01:00
|
|
|
dashedName: boo-who
|
2018-10-04 14:37:37 +01:00
|
|
|
---
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --description--
|
|
|
|
|
2018-10-04 14:37:37 +01:00
|
|
|
Check if a value is classified as a boolean primitive. Return true or false.
|
2020-11-27 19:02:05 +01:00
|
|
|
|
2018-10-04 14:37:37 +01:00
|
|
|
Boolean primitives are true and false.
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --hints--
|
|
|
|
|
|
|
|
`booWho(true)` should return true.
|
|
|
|
|
|
|
|
```js
|
|
|
|
assert.strictEqual(booWho(true), true);
|
2018-10-04 14:37:37 +01:00
|
|
|
```
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
`booWho(false)` should return true.
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
|
|
|
assert.strictEqual(booWho(false), true);
|
|
|
|
```
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
`booWho([1, 2, 3])` should return false.
|
2018-10-04 14:37:37 +01:00
|
|
|
|
|
|
|
```js
|
2020-11-27 19:02:05 +01:00
|
|
|
assert.strictEqual(booWho([1, 2, 3]), false);
|
|
|
|
```
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
`booWho([].slice)` should return false.
|
|
|
|
|
|
|
|
```js
|
|
|
|
assert.strictEqual(booWho([].slice), false);
|
|
|
|
```
|
|
|
|
|
|
|
|
`booWho({ "a": 1 })` should return false.
|
|
|
|
|
|
|
|
```js
|
|
|
|
assert.strictEqual(booWho({ a: 1 }), false);
|
|
|
|
```
|
|
|
|
|
|
|
|
`booWho(1)` should return false.
|
|
|
|
|
|
|
|
```js
|
|
|
|
assert.strictEqual(booWho(1), false);
|
2018-10-04 14:37:37 +01:00
|
|
|
```
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
`booWho(NaN)` should return false.
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
|
|
|
assert.strictEqual(booWho(NaN), false);
|
|
|
|
```
|
|
|
|
|
|
|
|
`booWho("a")` should return false.
|
|
|
|
|
|
|
|
```js
|
|
|
|
assert.strictEqual(booWho('a'), false);
|
|
|
|
```
|
|
|
|
|
|
|
|
`booWho("true")` should return false.
|
|
|
|
|
|
|
|
```js
|
|
|
|
assert.strictEqual(booWho('true'), false);
|
|
|
|
```
|
|
|
|
|
|
|
|
`booWho("false")` should return false.
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
|
|
|
assert.strictEqual(booWho('false'), false);
|
|
|
|
```
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --seed--
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
## --seed-contents--
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
|
|
|
function booWho(bool) {
|
|
|
|
return bool;
|
|
|
|
}
|
|
|
|
|
|
|
|
booWho(null);
|
|
|
|
```
|
|
|
|
|
|
|
|
# --solutions--
|
2018-10-04 14:37:37 +01:00
|
|
|
|
|
|
|
```js
|
|
|
|
function booWho(bool) {
|
|
|
|
return typeof bool === "boolean";
|
|
|
|
}
|
|
|
|
|
|
|
|
booWho(null);
|
|
|
|
```
|