A simple command-line game where you try to guess a random number between 1 and 100.
This is a fun and interactive number guessing game built with Node.js. The computer will randomly select a number between 1 and 100, and your task is to guess it correctly within the allowed number of attempts based on the difficulty level you choose.
- Three difficulty levels:
- Easy: 10 attempts
- Medium: 5 attempts
- Hard: 3 attempts
- Feedback after each guess to help you narrow down the correct number
- Remaining attempts counter
- Command-line interface for easy interaction
- Make sure you have Node.js installed on your system
- Clone this repository or download the files
- Navigate to the project directory
- Install dependencies:
npm install- Make the file executable (optional, for Unix/Linux/Mac):
chmod +x index.jsYou can run the game in two ways:
npm startnode index.jsFirst, install the package globally:
npm install -g .Then you can run it from anywhere:
gnumber-game1- Start the game using one of the methods above
- Select a difficulty level (1, 2, or 3)
- Enter your guess when prompted
- The game will tell you if your guess is too high or too low
- Keep guessing until you find the correct number or run out of attempts
- prompt-sync: ^4.2.0 - For synchronous command-line input
ISC
roadmap.sh: https://roadmap.sh/projects/number-guessing-game