JavaScript Foundations

Strings, numbers, and booleans

Meet three value types beginners see constantly in JavaScript: text, numbers, and true-or-false answers.

Starter 4 practice exercises 1 homework item

What you will learn

  • Meet three value types beginners see constantly in JavaScript: text, numbers, and true-or-false answers.
  • Tell strings, numbers, and booleans apart in tiny examples.
  • Understand where each value type fits in calm beginner code.

Lesson shape

14 minute lesson with 11 sections, 4 exercises, 8 checkpoint questions, and 1 homework submission.

Student mode saves sections, safe practice results, quiz progress, and completion status.

Lesson preview

Step-by-step structure before you start

Overview

What you will learn in this lesson

JavaScript can store different kinds of values. The good news is that beginners do not need a giant list first. You only need a few core value types to build a strong start.

In this lesson, you will focus on three beginner-safe value types:
- strings for text
- numbers for counting or measuring
- booleans for true-or-false answers

Your lesson goals are simple:
- understand what each value type means in plain English
- recognize the difference between text, numbers, and true-or-false values
- read tiny code examples without rushing
- feel calmer when JavaScript stores more than one kind of information

Three types are enough for now

If you can tell strings, numbers, and booleans apart, you already understand a big part of beginner JavaScript values.

Explain

What a string is in plain English

A string is text in code.

A string might hold a name, a greeting, a page message, or any other words the program needs to remember. Because a string is text, it usually appears inside quotes.

If the code stores "Hello" or "Ava", JavaScript treats that value as text, not as a number and not as an instruction.

Strings are words

If the value is text, it is usually a string and usually needs quotes.

Explain

What a number is in plain English

A number is a value used for counting, measuring, or simple math.

A number might store an age, a lesson count, a score, or the number of items in a list. When the value is truly numeric information, JavaScript can treat it like a number instead of like text.

Numbers are for amount

If the value is meant to count or measure something, it is often a number.

Explain

What a boolean is in plain English

A boolean is a value that can only be true or false.

This can feel unfamiliar at first because it is not ordinary text and it is not a count. A boolean is more like a simple yes-or-no answer the code can use later.

If the page needs to remember whether something is open, finished, or turned on, a boolean can help hold that answer clearly.

Booleans answer yes or no

A boolean does not hold any words or numbers. It only holds true or false.

Practice

Tiny example 1: a string value

Here is a tiny example:

let studentName = "Ava"

Line by line:
let starts a simple variable line.
studentName is the variable name.
"Ava" is the stored value.

Because the value is text, it is a string.

Text needs string treatment

A name like Ava is text, so JavaScript reads it as a string value.

Practice

Tiny example 2: a number value

Here is another example:

let lessonCount = 3

Line by line:
lessonCount is the variable name.
3 is the stored value.

Because the value is a count, JavaScript treats it as a number.

Counts are numbers

If the value is measuring or counting something, it usually belongs in number form.

Practice

Tiny example 3: a boolean value

One more example:

let isLoggedIn = true

Line by line:
isLoggedIn is the variable name.
true is the stored value.

Because the value answers a yes-or-no style question, JavaScript treats it as a boolean.

True and false are useful answers

A boolean helps code remember a simple state such as yes, no, on, off, open, or closed.

Explain

See the three value types side by side

These three examples may look small, but they do different jobs:

"Hello" is a string because it is text.
42 is a number because it is a count or amount.
false is a boolean because it is a true-or-false answer.

This side-by-side view helps because beginners often feel like every value should behave the same way. It does not. The type tells JavaScript how to understand the value.

Different value types, different jobs

Strings hold text. Numbers hold amounts. Booleans hold true-or-false answers.

Explain

Why booleans matter even if they feel unfamiliar

Booleans matter because code often needs very simple answers:

- Is the student logged in?
- Is the answer correct?
- Is the menu open?
- Is the lesson complete?

A boolean gives JavaScript a clear way to remember that kind of answer without extra words.

Booleans help decisions later

True and false may feel new, but they are one of the cleanest ways code keeps track of simple states.

Explain

Common beginner mistakes with value types

A few small mistakes happen often:

Putting quotes around numbers by accident:
"5" is text, while 5 is a number.

Forgetting that strings are text:
If the value is words, it should usually be treated like a string.

Not understanding what true and false are doing:
They are not random words. They are boolean values that answer a yes-or-no style question.

Assuming every value behaves the same way:
A string, number, and boolean may all look short, but JavaScript uses them differently.

Slow down and identify the kind of value

When a value feels confusing, ask whether it is text, a count, or a true-or-false answer.

Wrap up

Short recap before lesson 4

A string is text.
A number is a count or amount.
A boolean is true or false.

These are three of the most common beginner value types in JavaScript. If you can recognize which one you are looking at, you are building the right foundation for the next lesson.

Recognition is the win

You do not need advanced theory here. You only need to recognize what kind of value JavaScript is using.

Keep moving

Finish this lesson, then move forward without losing your place.

Use the student player for saved sections, safe practice, quiz progress, and completion tracking.