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