Roll the dice (advanced)
Solution
- When you first open the page:
- the default value for Number of dices is 3
- the default value for Number of rolls is 1
- Number of dices should be between 1 and 9, while the Number of rolls is limited to 10
- Show for every roll:
- the sum of all dices
- the average (rounded to maximum two decimal digits) of all dices
- one line with dice images (assets/dice/dice-n.png)
- If the sum of all dices on a line is EVEN: show the result inside a
div
tag with classbox-primary
- If the sum of all dices on a line is ODD: show the result inside a
div
tag with classbox-warning
Tip
Round the average with the functions round()
and number_format()
to see the
difference (in output)