📜  如何使用Javascript数学类的随机方法编写模拟抛硬币的程序 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:42.488000             🧑  作者: Mango

代码示例1
var head = 1;
var tail = 2;

var toss = Math.random() * 2;
var floor = Math.floor(toss)
if(floor === 0){
    document.write("0 
Random Coin Value: Head") } else if(floor === 1) { document.write("1
Random Coin Value: Tails") }