JavaScript & TypeScript / Quiz

== vs ===: The Coercion Trap

Loose versus strict equality, NaN, modulus and exponent, post-increment, and what the plus sign does to a string.

Difficulty
Easy
Format
Quiz
Points
100
Estimate
7 min

// MISSION BRIEF

Your Mission

Operators look simple until two different types meet. Then JavaScript converts one of them, and it does not always pick the one you expect.

For each snippet, predict exactly what Node prints. If the code throws, pick the error. Run nothing: read it the way the engine does, top to bottom.

Speed bonus active.

// FIRST CONTACT

Battle teaser

An API returns its status as the string "200". What does this print? If it throws, pick the error. console.log("200" == 200); console.log("200" === 200);

  1. Afalse, then true
  2. Bfalse, then false
  3. Ctrue, then true
  4. Dtrue, then false
Answers, scoring, hints, and the full battle stay sealed.

// SKILL TAGS

javascriptfundamentalsoperatorsequalitycoercion