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