Search⌘ K
AI Features

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.

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 instructions
function 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 program
function main(){
displayInstructions();
// Call for the function that takes input and storing its output
const rounds = getRounds();
}
Inventory of created functions

The next step is to ask the user about the number ...