Introduction
A number guessing game is a game such that in which a random number is generated, but you don't know the number.
Then you have to make successive guesses to find out the number. Each time you guess the number, the generator tells you how close you are to the number by telling to guess higher or lesser.
Resources required
- VS code or any IDE
- Node JS
- The basic knowledge of callback functions and event emitter
Tutorial
- Start by creating a JS file in VS code.
- Then import the readline module of Node JS.
- Create an instance of Interface class of readline module
- Now generate a random number using Math.floor and Math.random
- Now apply this logic to take input, check and if required then prompt for another input
-Finally, use the event emitter module to listen the close event and execute a callback function.
Top comments (0)