JS
…

Module 2 of 10

booleans

Work with true/false values, comparisons, and truthiness.

JavaScript Basics · 0/9 completed · scroll down for every challenge

Challenge 1 of 9

Compare numbers

Instructions

Set `isAdult` to true when `age` is greater than or equal to 18. `age` is already 21.

Editor

IntelliSense on

const age = 21;
// Write your code below

Challenge 2 of 9 · Logical AND

Challenge 2 of 9

Logical AND

Instructions

Given `hasTicket` and `hasId`, set `canEnter` to true only when both are true.

Editor

IntelliSense on

const hasTicket = true;
const hasId = true;
// Write your code below

Challenge 3 of 9 · Logical OR

Challenge 3 of 9

Logical OR

Instructions

Set `weekend` to true when `day` is `"Saturday"` or `"Sunday"`. `day` is `"Sunday"`.

Editor

IntelliSense on

const day = "Sunday";
// Write your code below

Challenge 4 of 9 · Negate a value

Challenge 4 of 9

Negate a value

Instructions

Set `isClosed` to the opposite of `isOpen`. `isOpen` is true.

Editor

IntelliSense on

const isOpen = true;
// Write your code below

Challenge 5 of 9 · Less than

Challenge 5 of 9

Less than

Instructions

Set `tooSmall` to true when `n` is less than 10. `n` is 4.

Editor

IntelliSense on

const n = 4;
// Write your code below

Challenge 6 of 9 · Boolean conversion

Challenge 6 of 9

Boolean conversion

Instructions

Store `Boolean(0)` in `flag`.

Editor

IntelliSense on

// Write your code below

Challenge 7 of 9 · Double bang

Challenge 7 of 9

Double bang

Instructions

Convert `value` to a boolean with `!!` and store it in `ok`. `value` is `"ready"`.

Editor

IntelliSense on

const value = "ready";
// Write your code below

Challenge 8 of 9 · Not equal

Challenge 8 of 9

Not equal

Instructions

Set `changed` to true when `status` is not `"draft"`. `status` is `"live"`.

Editor

IntelliSense on

const status = "live";
// Write your code below

Challenge 9 of 9 · XOR-style exclusive

Challenge 9 of 9

XOR-style exclusive

Instructions

Set `onlyOne` to true when exactly one of `a` or `b` is true.

Editor

IntelliSense on

const a = true;
const b = false;
// Write your code below

Next module