看来我的 if else 条件有语法错误,有人可以帮忙吗?控制台吐出这个链接 { /home/ccuser/workspace/javascript_101_Unit_3_v2/rockPaperScissors.js:38 }); } 和一个错误指向“)”
userInput = userInput.toLowerCase();
if (userInput !== "rock" && userInput !== "paper" && userInput !== "scissor") {
console.log("Error");
} else {
return userInput;
}
}
const getComputerChoice = () => {
const randomNumber = Math.floor(Math.random() * 3);
switch(randomNumber){
case 0: return "scissor";
break;
case 1: return "rock";
break;
default: return "paper";
break;
}
}
const determinWinner = (userChoice, computerChoice) => {
if(userChoice === computerChoice){
return "Its a tie";
} else if (userChoice === "rock" && computerChoice ==="scissor"){
return "The user won";
} else if (userChoice === "paper" && computerChoice ==="rock"){
return "The user won";
} else if (userChoice === "scissor" && computerChoice ==="paper"){
return "The user won";
} else if (userChoice === "rock" && computerChoice ==="paper"){
return "The computer won";
} else if (userChoice === "paper" && computerChoice ==="scissor"){
return "The computer won";
} else if (userChoice === "scissor" && computerChoice ==="rock"){
return "The computer won";
}
你定义了一个外壳,但你错过了决赛}
const determinWinner = (userChoice, computerChoice) => {
if(userChoice === computerChoice){
return "Its a tie";
} else if (userChoice === "rock" && computerChoice ==="scissor"){
return "The user won";
} else if (userChoice === "paper" && computerChoice ==="rock"){
return "The user won";
} else if (userChoice === "scissor" && computerChoice ==="paper"){
return "The user won";
} else if (userChoice === "rock" && computerChoice ==="paper"){
return "The computer won";
} else if (userChoice === "paper" && computerChoice ==="scissor"){
return "The computer won";
} else if (userChoice === "scissor" && computerChoice ==="rock"){
return "The computer won";
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句