else Statements, online
Six activities your students do on their own devices. See who's finished, and their scores.
Learning
Understanding
Testing
else Statements in one minute
What students need to know
else is exactly what catches every remaining case. Unlike if and else if, else never takes a condition.
else acts as the fallback when nothing else matched. JavaScript is case-sensitive, so 'else' must be lowercase.
Mistakes students make
- 'else' must be lowercase - a capital E causes an error.
- else never takes a condition in parentheses.
- 'else' is misspelled as 'els'.
- Code blocks use curly braces {}, not square brackets [].
PREVIOUS · MODULE 15else if Statements
YOU ARE HERE · MODULE 16else Statements
NEXT · MODULE 17Ternary Operator
What students will learn in this module
Every question in Module 16
Quick questions
- Does else run when every earlier condition was false?ANoBYes
- Does else have its own condition in parentheses?ANoBYes
- Must 'else' be written in lowercase?AYesBNo
- Can else come before an if statement in a chain?ANoBYes
- Does else's code block use curly braces?ANoBYes
Key terms
Students type the meaning of:
else
Match the pairs
} else { ... }Match it to what it doesif (score >= 70) { ... } else { ... }Match it to what it doesActs as the final fallback in a conditional chainMatch it to what it doesHas no condition of its ownMatch it to what it does} Else { console.log("Fail"); }Match it to what it does} else (age < 18) { ... }Match it to what it doesFill in the blanks
} ____ {Hint: Type the keyword used as the final fallback branch.
if (age >= 18) { } ____ { console.log("Minor"); }Hint: Type the keyword used as the final fallback branch.
if (n === 1) { } ____ { console.log("other"); }Hint: Type the keyword used as the final fallback branch.
if (temp > 30) { } ____ { console.log("Cool"); }Hint: Type the keyword used as the final fallback branch.
if (isOpen) { } ____ { console.log("Closed"); }Hint: Type the keyword used as the final fallback branch.
Spot the error
Question 1
Aif (score >= 70) {B} Else {Cconsole.log("Fail");D}
Question 2
Aif (age >= 18) {B} else (age < 18) {Cconsole.log("Minor");D}
Question 3
Aif (n === 1) {B} els {Cconsole.log("one");Dconsole.log("other");E}
Question 4
Aif (temp > 30) {Bconsole.log("Hot");C} else [Dconsole.log("Cool");E]
Question 5
Aif (isOpen) {Bconsole.log("Open");C} else {Dconsole.log("Closed")E}
