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,7 +7,13 @@ const rls = require('readline-sync')
* @returns {undefined}
*/
const startGame = () => {

if(rls.keyInYN('Ready to play? Y or N')) {
console.log("Let's start!")
gameLoop()
}else{
console.log('Have a nice life!')
quitGame()
}
}

/**
Expand All @@ -17,8 +23,9 @@ const startGame = () => {
* @returns {undefined}
*/
const quitGame = () => {

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

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

if(rls.keyInYN("Play again?")) {
startGame()
}else{
quitGame()
}
}


/***
* Generates a random number
*
Expand Down
Loading