Answers for "how to Write a program that simulates a coin toss using random method of Javascript Math class"

0

how to Write a program that simulates a coin toss using random method of Javascript Math class

var head = 1;
var tail = 2;

var toss = Math.random() * 2;
var floor = Math.floor(toss)
if(floor === 0){
    document.write("0 <br> Random Coin Value: Head")
} else if(floor === 1)
{
    document.write("1 <br> Random Coin Value: Tails")
}
Posted by: Guest on June-20-2020

Code answers related to "how to Write a program that simulates a coin toss using random method of Javascript Math class"

Code answers related to "Javascript"

Browse Popular Code Answers by Language