thecodezone.
The Code Zone
← Back to the Developer Playbook

Code Zone Bug Lab / Episode 19

Same Skill, New Accounts

Transfer your roster lookup skill to fictional observatory accounts. Build a small function that cleans input, searches approved aliases, and returns a standard account name.

DEV-162 · Arrays · objects · loops · cleaning input20 minutesNo setup or account required
Rob investigates Orion and Vega account aliases and checks the second account.
Rob investigates Orion and Vega account aliases and checks the second account.

Your sprint ticket · In progress · DEV-162

Give each fictional account one standard name.

Customer report: The pretend club writes the same account several ways. Our unfinished lookup returns no match for every input.

Steps to reproduce

  1. Read the two account objects in the JS tab.
  2. Predict the steps the function needs before writing code.
  3. Complete the TODOs, run your examples, then check your work.

Use the first word and the aliases supplied in ACCOUNTS. This exercise does not require punctuation handling. Do not add integrations, real account details, or substring matching.

Acceptance criteria

  • orion, Orion Observatory, ORION with surrounding spaces, and ori return Orion Observatory.
  • vega, Vega Observatory, VEGA with surrounding spaces, and veg return Vega Observatory.
  • Unknown names, empty strings, and whitespace-only input return an empty string.
  • null and other non-text values return an empty string without throwing.
  • orionette must not match orion.

Fictional learning demo. Use invented inputs only. No client systems or credentials are connected.

Reproduce → inspect → hypothesize → verify

Take the ticket.

Complete toAccount in the JavaScript tab. Rebuild the idea from memory before referring to Exercise A. Use the preview for your own tests, then Check challenge. Explain what you reused and what changed.

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.

    Check that spoken is a string. Use trim(), toLowerCase(), and split to get the first word. Loop over ACCOUNTS and check account.aliases.includes(first). Return account.name for a match and an empty string after the loop when no account matches.

    Try Vega to prove your function searches beyond the first object. Explain why orionette stays unmatched, and create a third fictional account with two aliases.

    Try first. Reveal one clue at a time.

    Need a lead?

    1. Use the same four steps.

    Check the input type, clean it, search the array, and return a name or an empty string.

    2. Read one account object.

    account.name is the standard output. account.aliases is the array of spellings you can match.

    3. Keep the no-match return after the loop.

    Returning an empty string inside the loop would stop at the first non-match and miss later accounts.

    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) ↗