← JavaScript

Type Conversion

Converts a value, like a string, into a number data type.

Understanding Type Conversion in JavaScript

What it does: Boolean() converts values like 1 into the boolean true. This converts the variable input into a number. Number() turns a value, like a string, into a number type. JavaScript requires a capital N: Number(). Number(x), String(x), and Boolean(x) all need parentheses. JavaScript's built-in function is Number(), not number(). Without parentheses, this isn't a valid function call.

Common mistakes: 'Number' must start with a capital N, not lowercase. 'String' must start with a capital S, not lowercase.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 1–10) and word search (Modules 1–29).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Does Number() convert a value into a number?
YesNo
Matches
let n = number("5");
↓
Wrong - 'Number' must start with a capital N
Applying
Meanings
Term
Number()
Meaning
Converts a value, like a string, into a number data type.
Practice
let age = 12;
Testing
Gaps
let ageText = (age);
Check Answer
Spots
1let num = "5";
2let x = number(num);

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Golden Eagle' badge — High Flyer, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Does Number() convert a value into a number?
A. No
B. Yes ✓
Number() turns a value, like a string, into a number type.
2. Does String() convert a value into a string?
A. Yes ✓
B. No
String() turns a value, like a number, into a string type.
3. Is 'number' with a lowercase n a valid conversion function?
A. No ✓
B. Yes
JavaScript requires a capital N: Number().
4. Does Boolean() convert a value into true or false?
A. No
B. Yes ✓
Boolean() converts values into the boolean true or false.
5. Do type conversion functions need parentheses around the value?
A. Yes ✓
B. No
Number(x), String(x), and Boolean(x) all need parentheses.

Match the Pairs

Number("5") → Converts the string "5" into the number 5
String(12) → Converts the number 12 into the string "12"
Converts a value into true or false → Boolean(1)
Turns text into a number data type → Number(input)
let n = number("5"); → Wrong - 'Number' must start with a capital N
let text = String age; → Wrong - String() needs parentheses around the value

Key Term

Number()
Converts a value, like a string, into a number data type.

Fill in the Blanks

1. let ageText = String(age);
Hint: Type the function that converts a value to a string.
2. let num = Number(input);
Hint: Type the function that converts a value to a number.
3. let flag = Boolean(1);
Hint: Type the function that converts a value to a boolean.
4. let count = Number("8");
Hint: Type the function that converts a value to a number.
5. let label = String(score);
Hint: Type the function that converts a value to a string.

Spot the Error

Question 1
A let num = "5";
B let x = number(num);
C console.log(x);
Line B — 'Number' must start with a capital N, not lowercase.
Question 2
A let age = 12;
B console.log(text);
C let text = string(age);
Line C — 'String' must start with a capital S, not lowercase.
Question 3
A let b = boolean(val);
B let val = 1;
C console.log(b);
Line A — 'Boolean' must start with a capital B, not lowercase.
Question 4
A let s = "9";
B let n = Number(s);
C let m = Numbr(s);
Line C — 'Number' is misspelled as 'Numbr'.
Question 5
A let age = 20;
B let txt2 = Sting(age);
C let txt = String(age);
Line B — 'String' is misspelled as 'Sting'.

Student with a class code? Join your class →