Click on play button after going through the instructions:
- Rock
- Paper
- Scissor
- For Rock
- For Paper
- For Scissor
Game is drawn if the user election matches with computers:
Player won against Computer.
Computer won against the player.
Generate a Random Number for computers.
If a random number between 1 and 4 Rock.
If a random number between 5 and 7 Paper.
Else take as Scissor
- var computerselection = "";
- var y = (Math.floor(Math.random() * 10) + 1);
-
- if (y >= 1 && y <= 4) {
- computerselection = "Rock";
- }
- else if (y >= 5 && y <= 7) {
- computerselection = "Paper";
- }
- else {
- computerselection = "Scissor";
- }
Used Bootstrap Alert and Prompt.
Simple if conditions to check who has won.
Here x is the User Selection from Prompt.
- if (x == values[computerselection])
- bootbox.alert("Game Draw--Better Luck Next Time");
-
- ---------------------------------------------------------------------------------------
- else if (values[computerselection] == 1 && x == 2)
- bootbox.alert("Computer have won Computer Selected " + computerselection);
-
- --------------------------------------------------------------------------------------------
-
- else if ((values[computerselection] == 1 && x == 3) || (values[computerselection] == 2 && x == 1) || (values[computerselection] == 3 && x == 2))
- bootbox.alert("Computer have won Computer Selected " + computerselection);
-
- ----------------------------------------------------------------------------------------------
-
- else if ((values[computerselection] == 1 && x == 2) || (values[computerselection] == 2 && x == 3) || (values[computerselection] == 3 && x == 1))
- bootbox.alert("You won against computer -- Computer Selected " + computerselection);