thecodezone.
The Code Zone
← Back to the Developer Playbook

Code Zone Bug Lab / Episode 10

The Age Gate That Lets Everyone In

This pretend gate requires age 18 or older and a demo ticket. One condition is slipping through.

DEV-153 · Comparisons · Boolean AND/OR15–20 minutesNo setup or account required
A fictional age gate admits a sixteen-year-old with a ticket even though both requirements are needed.
A fictional age gate admits a sixteen-year-old with a ticket even though both requirements are needed.

Your sprint ticket · In progress · DEV-153

The Age Gate That Lets Everyone In.

Customer report: I entered age 16 with a ticket checked, and this pretend 18+ gate granted access.

Steps to reproduce

  1. Keep age 16 and the demo-ticket box checked.
  2. Select Check demo access.
  3. Try age 18 without a ticket and compare the result.

Make a focused behavior fix. Styling and adding unrelated features belong to another ticket.

Acceptance criteria

  • Age 18 with a ticket is allowed.
  • Age 17 with a ticket is denied.
  • An adult without a ticket is denied.
  • A minor without a ticket is denied.
  • Older adults with a ticket remain allowed.

Learning demo only. No real accounts, purchases, authentication, or external requests.

Reproduce → inspect → hypothesize → verify

Take the ticket.

Reproduce the bug before editing. Inspect the Console and the JS tab. Explain one hypothesis, change the relevant code, then use Check challenge below the editor. Test the full ticket, not only the starter example. Reveal hints one at a time if needed.

Checking account and saved lab work…

Sign in to sync across devices

Loading the JavaScript and HTML editor…

Pass the checks or make three attempts to unlock an explained example.

Ready to test? Choose “Check challenge” after investigating.

    Open starter in a separate tab

    Code and prediction notes recover in this browser and sync when signed in. Instructor examples stay separate. Reset replaces code, not prediction notes.

    One possible solution

    Compare this approach with your own. Opening it does not change your code or mark the exercise complete.

    Return age >= 18 && hasTicket. The starter uses OR, so a ticket alone grants access, and an adult needs no ticket. Check both sides independently and include the exact boundary. This is a logic exercise, not a real security or age-verification system.

    Try first. Reveal one clue at a time.

    Need a lead?

    1. Read both requirements.

    Is meeting just one condition enough according to the ticket?

    2. Inspect the operator.

    || means either condition can be true. && requires both to be true.

    3. Check the boundary.

    Use age >= 18 && hasTicket. Eighteen is included in the allowed range.

    Your lab report

    Show your reasoning.

    “I expected… I observed… The console showed… My hypothesis was… I changed… I verified…”

    Use Check challenge for automated behavior checks. Passing checks are useful evidence, not a complete code review.

    Give others room to investigate: label solutions as spoilers.

    Share your lab report on SKOOL (new tab) ↗