Menu
CoddyTech

Guess Judge

Part of the PowerShell Basics section of Coddy's PowerShell journey. Lesson 28 of 28.

challenge icon

Challenge

Medium

Judge a number guessing game: the first input line is the secret number, and the next lines are guesses.

  1. Read the secret with the prompt Secret, then read guesses with the prompt Guess, at most 5 of them.
  2. After each guess, print Too low, Too high, or Correct in N tries! where N is the number of guesses so far. A correct guess ends the game.
  3. If 5 guesses were all wrong, print Out of tries. The number was , the secret and a full stop.

With the input 42, 50, 30 and 42, your script prints:

Secret: 42
Guess: 50
Too high
Guess: 30
Too low
Guess: 42
Correct in 3 tries!

Try it yourself

# Read the secret, then judge up to 5 guesses

All lessons in PowerShell Basics