Quizz
The full text of this chapter, to read or revisit. To practise, do the exercises.
βΆ Do the exercisesExercise 1 β Quiz: Comparison Result
What will this code print?
let level = 25;
console.log(level >= 25);truefalse25undefinedHint : 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);truefalse0TypeErrorHint : 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);truefalsenullundefinedHint : What does the AND operator require? Think about the truth table for &&.
Exercise 4 β Quiz: Truthy or Falsy?
Which of these values is truthy?
[] (empty array)"" (empty string)0nullHint : 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);PyrochuDefaulttrueundefinedHint : 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:
><====!==Exercise 7 β Quiz: NOT Operator
What is the output?
let isSleeping = true;
console.log(!isSleeping);falsetruenull1Hint : 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);falsetrue100"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);falsetrueundefinednullHint : 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
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:
NaN"NaN"-1""" "Exercise 12 β Quiz: Inequality Comparison
What is the result?
let damage = 45;
console.log(damage !== "45");truefalse45"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");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);truefalse1undefinedHint : 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);truefalse8015Hint : Evaluate each comparison separately, then apply the && logic. What does AND require?
Exercise 16 β Quiz: Logical Operators Meaning
Match each operator with its function:
&&||!===Exercise 17 β Quiz: Double NOT Operator
What does this output?
let codemonName = "Florachu";
console.log(!!codemonName);truefalse"Florachu"undefinedHint : 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);truefalse250300Hint : 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);truefalsenullundefinedHint : 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");No message"" (empty string)truefalseHint : 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:
5 == "5"5 === "5"0 == false0 === false"" == 0truefalsetruefalsetrueExercise 22 β Quiz: Operator Precedence
What is the result?
let result = true || false && false;
console.log(result);truefalseundefinednullHint : Which operator has higher precedence: && or ||? Evaluate in the correct order.
Exercise 23 β Quiz: Negative Numbers
What does this print?
console.log(Boolean(-5));truefalse-5undefinedHint : 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:
value || defaultcondition && action!value!!valueExercise 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);truefalse"Aquachu"0Hint : Break this down: evaluate the parentheses first, then apply &&. Remember truthy/falsy behavior.