• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Nov 16th, 2019 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. <script>
2. var player = 0;
3. var computer = 0;
4. var varplayerScore;
5. var computerScore;
6. var dice1 = Math.floor(Math.random() * 5) + 1;
7. var dice2 = Math.floor(Math.random() * 5) + 1;
8.
9. alert('Lets shake some dice!');
10.
11. while (player < 5 && computer < 5)
12.     {
13.         playerScore = dice1 + dice2;
14.             alert('Your turn to roll' + '\n You shook a ' + dice1 + ' and a ' + dice2 + ' , so you have ' + playerScore);
15.                 dice1 = Math.floor(Math.random() * 5) + 1;
16.                 dice2 = Math.floor(Math.random() * 5) + 1;
17.         computerScore = dice1 + dice2;
18.             alert('My turn to roll' + '\n I shook a ' + dice1 + ' and a ' + dice2 + ' , so I have ' + computerScore);
19.                 dice1 = Math.floor(Math.random() * 5) + 1;
20.                 dice2 = Math.floor(Math.random() * 5) + 1;
21.                 if (computerScore > playerScore)
22.                     {
23.                         computer++;
24.                     }
25.                 else if (computerScore < playerScore)
26.                     {
27.                         player++;
28.                     }
29.                 if (playerScore > computerScore)
30.                     {
31.                     alert('You win ' + playerScore + ' to ' + computerScore  + '\nYou are winning ' + player + ' to ' + computer)
32.                     }
33.                 else if (playerScore < computerScore)
34.                     {
35.                     alert('I win ' + computerScore + ' to ' + playerScore  + '\nI am winning ' + computer + ' to ' + player)
36.                     }
37.                 else if (playerScore == computerScore && player == computer)
38.                     {
39.                     alert('You win ' + playerScore + ' to ' + computerScore  + '\nThe score is tied ' + player + ' to ' + computer)
40.                     }
41.                 else if (playerScore == computerScore && player > computer)
42.                     {
43.                     alert('Tie!  Roll again!' + '\nYou are winning ' + player + ' to ' + computer)
44.                     }
45.                 else if(playerScore == computerScore && player < computer)
46.                     {
47.                     alert('Tie!  Roll again!' + '\nI am winning ' + computer + ' to ' + player)
48.                     }
49.     }
50. if (computer == 5)
51.     {
52.         alert('I win ' + computer + ' to ' + player + '\n I win the game!')
53.     }
54. else if (player == 5)
55.     {
56.     alert('You win ' + player + ' to ' + computer + '\n You win the game!')
57.     }
58. </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.
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!

Top