Roll the Dice
JavaScript
10 pts
Roll the Dice
Create a variable dice that holds a random whole number from 1 to 6. Use Math.random() and Math.floor().
Then print it with a label, for example:
Dice: 4
Your number will change every time you run the program — that is correct.
Checklist
- Create
dice, a whole number from 1 to 6. - Build it with
Math.random()andMath.floor(). - Print it as
Dice: ….
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
