$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · easy · #176

Which fix removes the bug?

const age = input.value;
if (age > 18) allow();
  1. Convert with Number()
  2. Compare against '18'
  3. Trim the input first
  4. Check the field exists
input.value is always a string, so the comparison relies on implicit coercion that fails on ''.
Play Problem Solving ▸