The Coercion Trap

HardAcc. 62.3%
+50 XP 15

Detecting The Trap

JavaScript's loose equality (==) can be dangerous. A "Coercion Trap" occurs when two values are considered equal by the loose operator (==), but are not equal under the strict operator (===).

The Assignment

Your function receives parameters a and b.

  1. Determine if they are in a "Coercion Trap".
  2. Return true if a == b is true, but a === b is false.
  3. Otherwise, return false.

01EXAMPLE 1

Inputa = 0, b = false
Outputtrue

Explanation: 0 == false is true, but they are different types (Trap).

Constraints

  • Compare loose and strict equality.
  • Return a boolean.
LogicComparisonMastery
JavaScript
Loading...
4 Hidden

Input Arguments

a0
bfalse

Expected Output

true

Click RUN to test your solution