Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions game.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@ const rls = require('readline-sync')
* @returns {undefined}
*/
const startGame = () => {

let playGame = rls.keyInYN('Do you want to play ? \n')
if (playGame) {
console.log("Let's start!")
gameLoop()
} else {
console.log('Have a nice life!')
quitGame()
}
}


/**
* Logs "Goodbye!"
* Calls process.exit() to quit the game
*
* @returns {undefined}
*/
const quitGame = () => {

console.log('Goodbye!')
}
process.exit()

/**
* Controls the flow of the game.
Expand All @@ -28,17 +37,18 @@ const quitGame = () => {
* @returns {undefined}
*/
const gameLoop = () => {

console.log('I have a random number in mind')
console.log('It\'s between 1 and 1000')
console.log('You have 10 guesses total')
}


/***
* Generates a random number
*
* @returns {number} - a number between 1 and 1000
*/
const generateRandomNumber = () => {

return Math.floor(Math.random() * 1000) + 1
}

startGame()
Expand Down
Loading