Skip to main content
JavaScript Bug Hunt Medium +20 XP

Equality Check Bug

This comparison always returns false even for matching values.

JavaScriptFind the bug
1function isEqual(a, b) {
2 if (a = b) {
3 return true;
4 }
5 return false;
6}
The bug is on line 2

Select the correct fix

Show answer and explanation

Answer: a === b

a = b is assignment, not comparison. Use === for strict equality.

Hint: = and === are very different.

What this challenge tests

Bug Hunt in JavaScript: operators, equality.

Related challenges