Guess Judge
Part of the PowerShell Basics section of Coddy's PowerShell journey. Lesson 28 of 28.
Challenge
MediumJudge a number guessing game: the first input line is the secret number, and the next lines are guesses.
- Read the secret with the prompt
Secret, then read guesses with the promptGuess, at most 5 of them. - After each guess, print
Too low,Too high, orCorrect in N tries!where N is the number of guesses so far. A correct guess ends the game. - 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
5Project: Password Checker
Project OverviewLength Check