这是我制作并尝试运行的嵌套脚本:
var coin = Math.round(Math.random() * 2);
var character = Math.round(Math.random() * 2);
if (character == 1) {
//It's a kid
if (coin == 0) {
alert("where'd the coin go?");
} else if (coin == 1) {
alert("you got heads dude");
} else if (coin== 2) {
alert("you got tails dude");
}
} else {
//now it's a computer
if (coin ==0) {
alert("3RR0R C01N G0N3");
} else if (coin==1) {
alert("H34D5");
} else if (coin==2) {
alert("T41L5");
}
可悲的是,什么都没有出现。有什么建议么?edit-t 更新为正确的代码格式,抱歉错误