Syncing account progress…

Back

Beginner · 8 min

Compare values

Create true or false results with strict comparisons and logical operators.

Check equality and size

A boolean is either true or false. === checks equality without converting between types. Use >, <, >=, and <= to compare numeric values.

console.log(3 === 3);
console.log(3 === "3");
console.log(8 >= 5);

Output

true
false
true

Combine conditions

For boolean values, && is true when both conditions are true. || is true when at least one condition is true. ! reverses a boolean.

const hasTicket = true;
const isOpen = false;
console.log(hasTicket && isOpen);
console.log(hasTicket || isOpen);

Output

false
true

Put it into practice

  1. Predict the output of each example before running it.
  2. Complete the coding task, then try the practice questions.

Try it yourself

Code runs on this device. When you are signed in, drafts sync to your account.

Check availability

Set available to the result of checking whether stock is greater than 0. Display available.

Practice