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