else Statements

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

This else Statements worksheet is part of the JavaScript Coding without HTML and CSS journey. Print it as a booklet?

else Statements

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Does else run when every earlier condition was false?
A No
B Yes
2. Does else have its own condition in parentheses?
A No
B Yes
3. Must 'else' be written in lowercase?
A Yes
B No
4. Can else come before an if statement in a chain?
A No
B Yes
5. Does else's code block use curly braces?
A No
B Yes

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1} else { ... } Aelse
2if (score >= 70) { ... } else { ... } BWrong - 'else' must be lowercase
3Acts as the final fallback in a conditional chain CRuns the else block only if score < 70
4Has no condition of its own DWrong - else never takes a condition in parentheses
5} Else { console.log("Fail"); } ERuns when every earlier condition in the chain was false
6} else (age < 18) { ... } F} else {

Definitions

else

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
} ____ {
2.
if (age >= 18) { } ____ { console.log("Minor"); }
3.
if (n === 1) { } ____ { console.log("other"); }
4.
if (temp > 30) { } ____ { console.log("Cool"); }
5.
if (isOpen) { } ____ { console.log("Closed"); }

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A if (score >= 70) {
B } Else {
C console.log("Fail");
D }
Question 2
A if (age >= 18) {
B } else (age < 18) {
C console.log("Minor");
D }
Question 3
A if (n === 1) {
B } els {
C console.log("one");
D console.log("other");
E }
Question 4
A if (temp > 30) {
B console.log("Hot");
C } else [
D console.log("Cool");
E ]
Question 5
A if (isOpen) {
B console.log("Open");
C } else {
D console.log("Closed")
E }

Answer Key

else Statements
Section A: Quick Questions
Q1
B — Yes
Q2
A — No
Q3
A — Yes
Q4
A — No
Q5
B — Yes
Section B: Match the Pairs
Q1
} else { ... } → Runs when every earlier condition in the chain was false
Q2
if (score >= 70) { ... } else { ... } → Runs the else block only if score < 70
Q3
Acts as the final fallback in a conditional chain → else
Q4
Has no condition of its own → } else {
Q5
} Else { console.log("Fail"); } → Wrong - 'else' must be lowercase
Q6
} else (age < 18) { ... } → Wrong - else never takes a condition in parentheses
Section C: Definitions
Q1
else — Runs a block of code when every earlier if or else if condition was false.
Section D: Fill in the Blanks
Q1
} else {
Q2
if (age >= 18) { } else { console.log("Minor"); }
Q3
if (n === 1) { } else { console.log("other"); }
Q4
if (temp > 30) { } else { console.log("Cool"); }
Q5
if (isOpen) { } else { console.log("Closed"); }
Section E: Spot the Error
Q1
B — 'else' must be lowercase - a capital E causes an error.
Q2
B — else never takes a condition in parentheses.
Q3
B — 'else' is misspelled as 'els'.
Q4
C — Code blocks use curly braces {}, not square brackets [].
Q5
D — This line is missing a semicolon, but that's not required in JS.