Roll the Dice
If you need a dice roller for a game, here you go
by estelle
HTML
<input type="number" min="1" max="6"> <input type="button" value="Roll">
<div id="dice"></div>
CSS
#dice {font-size: 6rem;}
JavaScript
document.querySelector('input[type=button]').addEventListener('click', function(){rollTheDice();});
var rollTheDice = function() {
var i,
faceValue,
output = '',
diceCount = document.querySelector('input[type=number]').value || 1;
for (i = 0; i < diceCount; i++) {
faceValue = Math.floor(Math.random() * 6);
output += "ɨ" + faceValue + "; ";
}
document.getElementById('dice').innerHTML = output;
}