Type Conversion, online
Six activities your students do on their own devices. See who's finished, and their scores.
Learning
Understanding
Testing
Type Conversion in one minute
What students need to know
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().
Mistakes students make
- 'Number' must start with a capital N, not lowercase.
- 'String' must start with a capital S, not lowercase.
- 'Boolean' must start with a capital B, not lowercase.
- 'Number' is misspelled as 'Numbr'.
PREVIOUS · MODULE 9typeof Operator
YOU ARE HERE · MODULE 10Type Conversion
NEXT · MODULE 11Comparison Operators
What students will learn in this module
Every question in Module 10
Quick questions
- Does Number() convert a value into a number?ANoBYes
- Does String() convert a value into a string?AYesBNo
- Is 'number' with a lowercase n a valid conversion function?ANoBYes
- Does Boolean() convert a value into true or false?ANoBYes
- Do type conversion functions need parentheses around the value?AYesBNo
Key terms
Students type the meaning of:
Number()
Match the pairs
Number("5")Match it to what it doesString(12)Match it to what it doesConverts a value into true or falseMatch it to what it doesTurns text into a number data typeMatch it to what it doeslet n = number("5");Match it to what it doeslet text = String age;Match it to what it doesFill in the blanks
let ageText = ______(age);
Hint: Type the function that converts a value to a string.
let num = ______(input);
Hint: Type the function that converts a value to a number.
let flag = _______(1);
Hint: Type the function that converts a value to a boolean.
let count = ______("8");Hint: Type the function that converts a value to a number.
let label = ______(score);
Hint: Type the function that converts a value to a string.
Spot the error
Question 1
Alet num = "5";Blet x = number(num);Cconsole.log(x);
Question 2
Alet age = 12;Bconsole.log(text);Clet text = string(age);
Question 3
Alet b = boolean(val);Blet val = 1;Cconsole.log(b);
Question 4
Alet s = "9";Blet n = Number(s);Clet m = Numbr(s);
Question 5
Alet age = 20;Blet txt2 = Sting(age);Clet txt = String(age);
