<script type="text/javascript">
var counter=0;
function generateRandom(){
var num=1+Math.floor(Math.random()*6)
if(counter%2==0){
document.getElementById("result").innerHTML= num;
document.getElementById("result").style.color = 'Red';
}
else{
document.getElementById("result").innerHTML= num;
document.getElementById("result").style.color = 'Green';
}
counter++;
}
</script>
<div id="result" style="font-size:100px"></div>
<input type="button" onClick="generateRandom()" value="Throw" style="width:70px; height:70px;font-size:20px;">
Next time if the dice are missing no need to make saddy face, just get a cup of coffee and open this in your browser and throw the dice.
Heart of the code
The code is so simple that even a 5 year child can understand.
Hey, remember no credit goes to me. It’s the Math.random()*6 which does everything. It is the heart of the program.
Bye, see you next time with more interesting articles.