Comparison Operators

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

Comparison Operators

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Does === check if two values are equal in both value and type?
A Yes
B No
2. Does !== check if two values are not strictly equal?
A No
B Yes
3. Is = a valid way to check if two values are equal?
A No
B Yes
4. Does > check if the left value is greater than the right?
A Yes
B No
5. Does < check if the left value is smaller than the right?
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
15 === 5 AReturns true because both values and types match
25 !== 3 BWrong - the strict inequality operator is !==, not !===
3Compares if one value is greater than another CReturns true because the values are not equal
4Compares if one value is less than another DWrong - use === for comparison, = is for assignment
5console.log(5 = 5); E10 > 7
6console.log(5 !=== 3); F3 < 8

Definitions

===

Fill in the Blanks

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

1.
console.log(5 ___ 5);
2.
console.log(5 ___ 3);
3.
console.log(10 _ 7);
4.
console.log(3 _ 8);
5.
let isEqual = age ___ 12;

Spot the Error

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

Question 1
A console.log(5 = 5);
B console.log(5 === 5);
C console.log(5 !== 3);
Question 2
A console.log(5 !== 3);
B console.log(5 !=== 3);
C console.log(10 > 7);
Question 3
A console.log(10 =< 7);
B console.log(10 > 7);
C console.log(3 < 8);
Question 4
A let a = 5 === 5;
B let b = 5 => 3;
C let c = 3 < 8;
Question 5
A let x = 5 === 5;
B let y = 5 !== 3;
C let z = age == 12;
D let w = 10 > 7;

Answer Key

Comparison Operators
Section A: Quick Questions
Q1
A — Yes
Q2
B — Yes
Q3
A — No
Q4
A — Yes
Q5
B — Yes
Section B: Match the Pairs
Q1
5 === 5 → Returns true because both values and types match
Q2
5 !== 3 → Returns true because the values are not equal
Q3
Compares if one value is greater than another → 10 > 7
Q4
Compares if one value is less than another → 3 < 8
Q5
console.log(5 = 5); → Wrong - use === for comparison, = is for assignment
Q6
console.log(5 !=== 3); → Wrong - the strict inequality operator is !==, not !===
Section C: Definitions
Q1
=== — Checks if two values are equal in both value and type, returning true or false.
Section D: Fill in the Blanks
Q1
console.log(5 === 5);
Q2
console.log(5 !== 3);
Q3
console.log(10 > 7);
Q4
console.log(3 < 8);
Q5
let isEqual = age === 12;
Section E: Spot the Error
Q1
A — Use === for comparison, not =, which is for assignment.
Q2
B — The strict inequality operator is !==, not !===.
Q3
A — Use <= not =<, to check less than or equal.
Q4
B — => is not a comparison operator - use >= for this check.
Q5
C — This module uses ===, not the loose ==, for equality checks.