James McGrath

Quick tips, in-depth guides, and thoughts on the future of the web

What Is a Boolean?

🧪 Concept:

A Boolean is a type of value that’s either true or false. That’s it — just those two options.

Booleans are used to answer yes-or-no questions in code, like:

let isSunny = true;
let hasUmbrella = false;

These values are especially useful when making decisions with if statements or controlling logic in your program.

🧰 Why It Matters:

Booleans are the building blocks of logic in code. They help your program know what to do — and when.

🎉 Quick Challenge:

Try creating a couple of Boolean values about yourself:

let likesPizza = true;
let hasCat = false;

Then use one in an if statement:

if (likesPizza) {
console.log("Same here 🍕");
}

🧠 Fun Analogy:

A Boolean is like a light switch — it’s either ON or OFF. No maybes.

📚 Further Reading:

MDN Docs – Boolean
W3Schools – JavaScript Booleans

Subscribe to my feed to follow along. I’ll keep the lessons short and sweet.

What Is a Return Statement?

One response to “What Is a Boolean?”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.