Dice game 1 player Roll the dice to begin the game The dice appears on the first roll When a dice is rolled, the score adds up Once the score passed, 20, you win. However, if you hit ‘1’ then you lose (if less than score of 20) If the player won or lost, the player can start the game again You may want to change the score to any number other than 20
- Create HTML with img div for the dice.
- Add a button to the HTML for 'roll dice'
- Add a p tag to track the score.
- Add a p tag to display 'winner' or 'loser' HTML COMPLETE
JS
- Button component - call the button element from HTML.
- Give the button a click function
- Make something appear in the console when the button is clicked.
- Make a random number function that max's out at 6 and cannot be a decimal.
- Log that random number to the console.
- connect the random number element to the button 'oncilck' method.
a - add the random numbers together untill they reach 20. Then stop. - console.log you've won. b - if the random number is 1 - stop - console log - you lose.
-
Pull the 'score tracker' p element from the HTML.
-
Display the random number in the score tracker.
-
Pull the 'display winner or loser' from the HTML.
-
Change the console log of the random numbers to a display random number within the winner/loser p tag.
-
After this alert appears give the player the option to play again.
-
Connect the dice images to the random number generator with an IF statement.