The Console Game Pack

Beginner · 90 min build · 🏆 milestone project

You are past isolated examples now. This project asks you to build a small console game pack, a text program with a menu, a number-guessing game, and a rock-paper-scissors bot, using only the Part I tools you already know.

Your goal is comfort, not cleverness. Read input, convert strings, compare values, choose branches, and repeat with loops. Keep the code plain: no functions, no arrays, no objects, no DOM, no imports, and no timers yet.

What you'll build

You will build one console workspace with three menu routes:

  • 1: a number-guessing game.
  • 2: a rock-paper-scissors bot.
  • 7: an exit route.

A route is one path the program takes after a menu choice. The scaffold is starter code with comments that show where each part belongs. The acceptance criteria are checks you can run yourself to prove a stage works.

javascript — live consolereal engine
⌘/Ctrl + Enter to run

Checkpoint 1: the menu routes

Start with the menu. It is the front desk for the whole pack: the user chooses one route, and JavaScript sends the program into the right branch.

Acceptance criteria:

  • Entering 7 prints Goodbye.
  • Entering 1 reaches the number game route.
  • Entering 2 reaches the rock-paper-scissors route.
  • Entering another value prints a clear fallback message.
  • The menu uses if / else if / else, not a loop that can trap the user forever.

Checkpoint 2: the number-guessing game

The number game practices prompt(), Number(), comparisons, for, break, and a small flag, a boolean variable that remembers whether something happened.

Keep the first secret fixed. A fixed value is easier to test than a hidden random one. If you want a different secret, derive it from typed setup input instead of Math.random(); guessing still needs later prompts.

Acceptance criteria:

  • The player gets a limited number of guesses.
  • Each prompt says which attempt they are on.
  • A low guess prints Too low; a high guess prints Too high.
  • A correct guess prints how many attempts it took and exits the loop with break.
  • Running out of attempts prints the secret number.
  • Changing secretNumber at the top changes the answer everywhere.

Checkpoint 3: the rock-paper-scissors bot

This route practices string cleanup, exact comparisons, conditionals, and a small random choice. Ask the player for a move first, then compute the bot move.

Acceptance criteria:

  • The player can type rock, paper, or scissors.
  • Extra spaces and uppercase letters still work because you use .trim().toLowerCase().
  • Invalid input prints a friendly message instead of pretending the move is real.
  • The bot chooses one of the three moves after the player prompt.
  • Ties, player wins, and bot wins all print clearly.
  • The code uses === for every equality check.

Checkpoint 4: test the whole pack

Do not trust a program because one path worked once. Walk every route like a careful player.

Acceptance criteria:

  • Choice 1 works for a win, a low guess, a high guess, and running out of attempts.
  • Choice 2 works for a tie, a player win, a bot win, and invalid input.
  • Choice 7 exits cleanly.
  • An unknown menu choice prints the fallback message.
  • No route uses functions, arrays, objects, DOM, imports, modules, timers, or unbounded loops.

Stretch goals

Choose one or two after the base pack works:

  • Let the number game ask for a difficulty and choose attemptsAllowed from that answer.
  • Derive the secret number from a setup answer, so no random work happens before guess prompts.
  • Add a 3 route for a tiny password checker with three allowed attempts.
  • In Section 5, refactor each route into a function.
  • In Section 6, store repeated test cases in arrays.

How to get unstuck

If input acts like text, revisit lesson 2.4 and check each Number() conversion. If a branch goes the wrong way, trace the condition with lesson 4.1 and lesson 4.2. If the menu or winner logic gets tangled, flatten it with lesson 4.3. If a loop will not stop or runs once too many, compare it to lesson 4.4.

You have finished Part I when this pack feels understandable, not magical. Next, functions give names to reusable chunks of work, so this project can become cleaner without becoming clever.

+50 XP on completion