View the code for this project on GitHub or CodePen.


The kids and I love LEGO and we have quite a few Minifigs. I thought it would be fun to have people guess how many I could fit into a Mason jar. Since this number isn't ever going to change, it's not something they would play over and over again. I think my site's 404 error page would make a good home for this reason. That way some people will come across it but


  • A player has 5 guesses per game
  • The game is over once a player guesses the correct number of Minifigs or they run out of turns

Game Logic

  • Allow only numbers to be input.
  • Accept input from the regular number keys and also the number/key pad.
  • Allow the user to enter a guess by clicking the button or pressing enter.
  • Allow a maximum of 5 guesses per game.
  • Allow the user to play again once the game is over.
  • Prevent a user from guessing the same number twice.
  • Limit number of digits per guess to 4. Example: 1234.
  • Set focus to "Play Again" button when game is over.
  • Disable input field when game is over.