cf.Show();
我似乎无法看到我的代码存在问题,我一直在尝试解决它,但它一直在说语法错误:无效或意外的令牌。
我只是开始学习var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice <= 0.33) {
computerChoice = "rock";
}
else if(computerChoice > 0.34 && computerChoice < 0.66) {
computerChoice = "paper";
}
else {
computerChoice = "scissors";
}
var compare=function(choice1,choice2){
if(choice1 === choice2){
return "The result is a tie!";
}
else if(choice1 === "rock"){
if(choice2 ==="scissors"){
return "rock wins";
}
else{
return "paper wins";
}
}
else if(choice1 ==="paper"){
if(choice2 ==="rock"){
return "paper wins";
}
else{
return "scissors wins";
}
}
else{
if(choice2 === paper){
return "scissors wins';
}
else{
return "rock wins";
}
}
};
compare(userChoice,computerChoice);
console.log(compare);
,我试图学习的网站只给出了很少的关于如何完成这项工作的信息。它不是帮助,而是在最后一小时内打印javascript
。
答案 0 :(得分:1)
您在scissors wins
之后混淆双引号的单引号。替换这个:
return "scissors wins';
由此:
return "scissors wins";