Loading...
beginner
Problem 01 • Step 03
Game Over
The game never ends. You can keep guessing past zero. Look at game.html to see what happens after each guess: it checks isGameOver, and if true, shows a message and disables the input. But those functions do not exist yet.
isGameOver(state)
Returns true if the game has ended. Either the word is fully guessed or guessesRemaining has reached 0.
didPlayerWin(state)
Returns true only if the word is fully guessed. Running out of guesses is game over but not a win.
Winning is a subset of game-over. Your tests should make this distinction clear. Test both the winning and losing scenarios for each function.
Examples
// Mid-game
isGameOver({ word: "apple", guessedLetters: ["a"], guessesRemaining: 5 })
// false
// Won
isGameOver({ word: "hi", guessedLetters: ["h", "i"], guessesRemaining: 4 })
// true
didPlayerWin({ word: "hi", guessedLetters: ["h", "i"], guessesRemaining: 4 })
// true
// Lost
isGameOver({ word: "hi", guessedLetters: ["x", "y", "z", "q", "w", "r"], guessesRemaining: 0 })
// true
didPlayerWin({ word: "hi", guessedLetters: ["x", "y", "z", "q", "w", "r"], guessesRemaining: 0 })
// false