$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #164

Which fix removes the bug?

if (user.age = 18) {
  grantAccess();
}
  1. Compare with ===
  2. Wrap it in Boolean()
  3. Check for null first
  4. Use >= instead
A single = assigns and yields 18, which is truthy, so the branch always runs.
Play Problem Solving ▸