Quizz

The full text of this chapter, to read or revisit. To practise, do the exercises.

β–Ά Do the exercises

Exercise 1 β€” Quiz: Comparison Result

What will this code print?

let level = 25; console.log(level >= 25);
Options
β€’ true
β€’ false
β€’ 25
β€’ undefined

Hint : Think about what >= means. Does the comparison include equality or just greater than?

Exercise 2 β€” Quiz: Equality with Type Coercion

What does this comparison return?

console.log(false == 0);
Options
β€’ true
β€’ false
β€’ 0
β€’ TypeError

Hint : Remember that == allows type coercion. How does JavaScript convert boolean values to numbers?

Exercise 3 β€” Quiz: AND Operator Logic

What is the result?

let hasWater = true; let hasPlant = false; console.log(hasWater && hasPlant);
Options
β€’ true
β€’ false
β€’ null
β€’ undefined

Hint : What does the AND operator require? Think about the truth table for &&.

Exercise 4 β€” Quiz: Truthy or Falsy?

Which of these values is truthy?

Options
β€’ [] (empty array)
β€’ "" (empty string)
β€’ 0
β€’ null

Hint : Remember the 6 falsy values. Does any of these match those specific values?

Exercise 5 β€” Quiz: Short-Circuit with OR

What will be printed?

let name = "Pyrochu"; let result = name || "Default"; console.log(result);
Options
β€’ Pyrochu
β€’ Default
β€’ true
β€’ undefined

Hint : With ||, what happens when the left side is truthy? Does it need to check the right side?

Exercise 6 β€” Quiz: Match Comparison Operators

Match each operator with its meaning:

Items to match
β€’ >
β€’ <=
β€’ ===
β€’ !==
Definitions
β€’ Greater than
β€’ Less than or equal to
β€’ Strictly equal to
β€’ Strictly not equal to

Exercise 7 β€” Quiz: NOT Operator

What is the output?

let isSleeping = true; console.log(!isSleeping);
Options
β€’ false
β€’ true
β€’ null
β€’ 1

Hint : What does the NOT operator do to boolean values? It flips them to their opposite.

Exercise 8 β€” Quiz: Strict Equality

What does this return?

console.log("100" === 100);
Options
β€’ false
β€’ true
β€’ 100
β€’ "100"

Hint : Remember that === checks both value AND type. Are both sides the same type?

Exercise 9 β€” Quiz: OR Operator Result

What will this print?

let canEvolve = false; let hasStone = false; console.log(canEvolve || hasStone);
Options
β€’ false
β€’ true
β€’ undefined
β€’ null

Hint : The OR operator needs at least one truthy value. How many truthy values do you see?

Exercise 10 β€” Quiz: Identifying Falsy

How many of these values are falsy? null, "hello", undefined, 42

Options
β€’ 2
β€’ 1
β€’ 3
β€’ 4

Hint : Think about the 6 falsy values you learned. Which ones appear in this list?

Exercise 11 β€” Quiz: Truthy vs Falsy Classification

Match each value with its classification:

Items to match
β€’ NaN
β€’ "NaN"
β€’ -1
β€’ ""
β€’ " "
Definitions
β€’ Falsy
β€’ Truthy
β€’ Truthy
β€’ Falsy
β€’ Truthy

Exercise 12 β€” Quiz: Inequality Comparison

What is the result?

let damage = 45; console.log(damage !== "45");
Options
β€’ true
β€’ false
β€’ 45
β€’ "45"

Hint : Does !== perform type coercion? What does 'strictly not equal' mean?

Exercise 13 β€” Quiz: Short-Circuit AND

How many messages will be printed?

false && console.log("Message 1"); true && console.log("Message 2"); true && console.log("Message 3");
Options
β€’ 2 messages
β€’ 3 messages
β€’ 1 message
β€’ 0 messages

Hint : Think about short-circuit evaluation with &&. When does the right side execute?

Exercise 14 β€” Quiz: Type Coercion Surprise

What does this comparison return?

console.log(true == 1);
Options
β€’ true
β€’ false
β€’ 1
β€’ undefined

Hint : Remember that == allows type coercion. What number does true convert to?

Exercise 15 β€” Quiz: Combining Operators

What is the output?

let hp = 80; let level = 15; console.log(hp > 50 && level < 20);
Options
β€’ true
β€’ false
β€’ 80
β€’ 15

Hint : Evaluate each comparison separately, then apply the && logic. What does AND require?

Exercise 16 β€” Quiz: Logical Operators Meaning

Match each operator with its function:

Items to match
β€’ &&
β€’ ||
β€’ !
β€’ ===
Definitions
β€’ Returns true if both conditions are true
β€’ Returns true if at least one condition is true
β€’ Inverts the boolean value
β€’ Checks equality without type coercion

Exercise 17 β€” Quiz: Double NOT Operator

What does this output?

let codemonName = "Florachu"; console.log(!!codemonName);
Options
β€’ true
β€’ false
β€’ "Florachu"
β€’ undefined

Hint : Double NOT converts any value to a boolean. Is the original value truthy or falsy?

Exercise 18 β€” Quiz: Less Than Comparison

What is the result?

let exp = 250; let neededExp = 300; console.log(exp < neededExp);
Options
β€’ true
β€’ false
β€’ 250
β€’ 300

Hint : Compare the two numbers. What does the < operator check for?

Exercise 19 β€” Quiz: Loose Equality Edge Case

What does this return?

console.log(null == undefined);
Options
β€’ true
β€’ false
β€’ null
β€’ undefined

Hint : This is one of JavaScript's special cases with ==. These two values have unique behavior.

Exercise 20 β€” Quiz: Empty String Behavior

What will be the output?

let message = ""; console.log(message || "No message");
Options
β€’ No message
β€’ "" (empty string)
β€’ true
β€’ false

Hint : Is an empty string truthy or falsy? What does || do with falsy values?

Exercise 21 β€” Quiz: Equality Operator Results

Match each comparison with its result:

Items to match
β€’ 5 == "5"
β€’ 5 === "5"
β€’ 0 == false
β€’ 0 === false
β€’ "" == 0
Definitions
β€’ true
β€’ false
β€’ true
β€’ false
β€’ true

Exercise 22 β€” Quiz: Operator Precedence

What is the result?

let result = true || false && false; console.log(result);
Options
β€’ true
β€’ false
β€’ undefined
β€’ null

Hint : Which operator has higher precedence: && or ||? Evaluate in the correct order.

Exercise 23 β€” Quiz: Negative Numbers

What does this print?

console.log(Boolean(-5));
Options
β€’ true
β€’ false
β€’ -5
β€’ undefined

Hint : Which number is the only falsy number? Are negative numbers included in that?

Exercise 24 β€” Quiz: Short-Circuit Patterns

Match each pattern with its use case:

Items to match
β€’ value || default
β€’ condition && action
β€’ !value
β€’ !!value
Definitions
β€’ Provide a default value
β€’ Execute code conditionally
β€’ Invert a boolean
β€’ Convert to boolean

Exercise 25 β€” Quiz: Combining All Concepts

What will this complex expression return?

let hp = 0; let name = "Aquachu"; let result = (hp > 0 || name) && !hp; console.log(result);
Options
β€’ true
β€’ false
β€’ "Aquachu"
β€’ 0

Hint : Break this down: evaluate the parentheses first, then apply &&. Remember truthy/falsy behavior.

Back to the course