Menu
Coddy logo textTech

Boolean

Part of the Fundamentals section of Coddy's JavaScript journey — lesson 7 of 77.

A Boolean (or bool) is a data type that has only two possible values:

  • true
  • false

You can store a Boolean value in a variable like this:

let isRaining = true;
let hasAccess = false;

In this example, isRaining is set to true, and hasAccess is set to false.

Booleans are the building blocks for creating logic in the programs we write. We have a whole chapter about logic and conditions.

challenge icon

Challenge

Beginner

Declare a variable named boolean and assign it the value true.

Cheat sheet

A bool (Boolean) type has only 2 possible values: true or false.

You can store a Boolean value in a variable like this:

let isRaining = true;
let hasAccess = false;

Try it yourself

// Type your code below
let boolean = ?

// Don't change the line below
console.log(`boolean = ${boolean}`)
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals