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.
- Determine if they are in a "Coercion Trap".
- Return
trueifa == bis true, buta === bis false. - Otherwise, return
false.
01EXAMPLE 1
Input
a = 0, b = falseOutput
trueExplanation: 0 == false is true, but they are different types (Trap).
Constraints
- Compare loose and strict equality.
- Return a boolean.
LogicComparisonMastery
JavaScriptSystem handles I/O — write your function only
Loading...
4 Hidden
Input Arguments
a0
bfalse
Expected Output
true
Click RUN to test your solution