freeCodeCamp/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/boo-who.md
Anna 6fa282cb6f
Some checks failed
i18n - Build Validation / Validate i18n Builds (20.x) (push) Has been cancelled
CI - Node.js / Lint (20.x) (push) Has been cancelled
CI - Node.js / Build (20.x) (push) Has been cancelled
CI - Node.js / Test (20.x) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (20.x) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 20.x) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 20.x) (push) Has been cancelled
i18n - Download Client UI / Client (push) Has been cancelled
chore(curriculum): update asserts in legacy basic algorithm scripting (#57784)
Co-authored-by: Naomi <accounts+github@nhcarrigan.com>
2025-01-04 13:10:00 +01:00

1.3 KiB

id title challengeType forumTopicId dashedName
a77dbc43c33f39daa4429b4f Boo who 1 16000 boo-who

--description--

Check if a value is classified as a boolean primitive. Return true or false.

Boolean primitives are true and false.

--hints--

booWho(true) should return true.

assert.isTrue(booWho(true));

booWho(false) should return true.

assert.isTrue(booWho(false));

booWho([1, 2, 3]) should return false.

assert.isFalse(booWho([1, 2, 3]));

booWho([].slice) should return false.

assert.isFalse(booWho([].slice));

booWho({ "a": 1 }) should return false.

assert.isFalse(booWho({ a: 1 }));

booWho(1) should return false.

assert.isFalse(booWho(1));

booWho(NaN) should return false.

assert.isFalse(booWho(NaN));

booWho("a") should return false.

assert.isFalse(booWho('a'));

booWho("true") should return false.

assert.isFalse(booWho('true'));

booWho("false") should return false.

assert.isFalse(booWho('false'));

--seed--

--seed-contents--

function booWho(bool) {
  return bool;
}

booWho(null);

--solutions--

function booWho(bool) {
  return typeof bool === 'boolean';
}

booWho(null);