我已经尝试了一切,但我被卡住了。有人可以查看我的代码,看看我错过了什么吗?我正在制作一个摇滚,纸张,剪刀和#39;游戏。
var userChoice = prompt("Do you choose rock, paper, scissors, lizard, or spock?");
var computerChoice = Math.random();
if (computerChoice < 0.16) {
computerChoice = "rock";
} else if(computerChoice <= 0.36) {
computerChoice = "paper";
}
else if(computerChoice <= 0.56){
computerChoice = "scissors";
}
else if(computerChoice <= 0.76){
computerChoice = "lizard";
}
else {
computerChoice = "spock";
}
var compare = function(userChoice, computerChoice) {
if (userChoice === computerChoice) {
return"It's a tie!"}
我有一个附加到js文件的html doc。我想在按下按钮后显示userChoice
。