我的代码显示带有右括号的意外标记错误)。什么意思?
我尝试添加和删除括号和大括号。
const getUserChoice = userInput => {userInput = userInput.toLowerCase();
if(userInput === 'rock' || userInput === 'paper' || userInput === 'scissors') {
return userInput;
} else {
console.log('Error! That's not part of the game!');
}
它不应该记录任何内容,而是记录错误。
代码中存在语法错误。您忘记添加缺少的末端(}
)大括号。
您使用过:
const getUserChoice = userInput => {userInput = userInput.toLowerCase();
而不是:
const getUserChoice = userInput => {userInput = userInput.toLowerCase();}
你能看到you haved used
示例中缺少的大括号吗?
提示:遵循@grumbler_chester建议。使用代码编辑器或 IDE 进行语法突出显示。