Get the Number of Rounds
Learn to create a function that asks the user for the number of rounds in the Rock Paper Scissors game, converts the input to an integer, and stores it for game control.
We'll cover the following...
We'll cover the following...
What have we got?
We have set up a function to print the introduction of the game. This is our inventory of already created functions:
// Function to display game instructionsfunction displayInstructions(){console.log('Welcome to Rock Paper Scissors.\n');console.log('The rules are simple:');console.log('1. Rock beats scissors');console.log('2. Scissors beat paper');console.log('3. Paper beats rock');}// Function to contain the flow of the whole programfunction main(){displayInstructions();// Call for the function that takes input and storing its outputconst rounds = getRounds();}
Inventory of created functions
The next step is to ask the user about the number ...