SHARE
TWEET

Untitled

a guest Nov 16th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var dice1 = Math.floor(Math.random() * 5) + 1;
  2. var dice2 = Math.floor(Math.random() * 5) + 1;
  3.  
  4. alert('Lets shake some dice!');
  5.  
  6. while (player < 5 && computer < 5)
  7.     {
  8.         playerScore = dice1 + dice2;
  9.             alert('Your turn to roll' + '\n You shook a ' + dice1 + ' and a ' + dice2 + ' , so you have ' + playerScore);
  10.                 dice1 = Math.floor(Math.random() * 5) + 1;
  11.                 dice2 = Math.floor(Math.random() * 5) + 1;
  12.         computerScore = dice1 + dice2;
  13.             alert('My turn to roll' + '\n I shook a ' + dice1 + ' and a ' + dice2 + ' , so I have ' + computerScore);
  14.                 dice1 = Math.floor(Math.random() * 5) + 1;
  15.                 dice2 = Math.floor(Math.random() * 5) + 1;
  16.                 if (computerScore > playerScore)
  17.                     {
  18.                         computer++;
  19.                     }
  20.                 else if (computerScore < playerScore)
  21.                     {  
  22.                         player++;
  23.                     }
  24.                 if (playerScore > computerScore)
  25.                     {
  26.                     alert('You win ' + playerScore + ' to ' + computerScore  + '\nYou are winning ' + player + ' to ' + computer)
  27.                     }
  28.                 else if (playerScore < computerScore)
  29.                     {
  30.                     alert('I win ' + computerScore + ' to ' + playerScore  + '\nI am winning ' + computer + ' to ' + player)
  31.                     }
  32.                 if (playerScore == computerScore && player == computer)
  33.                     {
  34.                     alert('You win ' + playerScore + ' to ' + computerScore  + '\nThe score is tied ' + player + ' to ' + computer)
  35.                     }
  36.                 else if (playerScore == computerScore && player > computer)
  37.                     {
  38.                     alert('Tie!  Roll again!' + '\nYou are winning ' + player + ' to ' + computer)
  39.                     }
  40.                 else if(playerScore == computerScore && player < computer)
  41.                     {
  42.                     alert('Tie!  Roll again!' + '\nI am winning ' + computer + ' to ' + player)
  43.                     }
  44.                
  45.     }
  46.     if (computer == 5)
  47.                     {
  48.                     alert('I win ' + computer + ' to ' + player + '\n I win the game!')
  49.                     }
  50.     else if (player == 5)
  51.                     {
  52.                     alert('You win ' + player + ' to ' + computer + '\n You win the game!')
  53.                     }
  54.  
  55. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top