Javascript 领带上仍有赢家信息?

Javascript 领带上仍有赢家信息?,javascript,if-statement,Javascript,If Statement,我一直在胡闹一个石头,剪纸的项目,codecademy让你尝试,我很高兴,但我有一个问题!当结果是平局时,它会记录平局消息(完美!),但也会记录与结果相关联的获胜消息! 如何让它只记录tie消息? 代码如下: const getUserChoice=userInput=>{ userInput=userInput.toLowerCase(); 如果(userInput==“rock”| | userInput==“paper”| | userInput==“剪刀”| | userInput==

我一直在胡闹一个石头,剪纸的项目,codecademy让你尝试,我很高兴,但我有一个问题!当结果是平局时,它会记录平局消息(完美!),但也会记录与结果相关联的获胜消息! 如何让它只记录tie消息? 代码如下:

const getUserChoice=userInput=>{
userInput=userInput.toLowerCase();
如果(userInput==“rock”| | userInput==“paper”| | userInput==“剪刀”| | userInput==“gun”){
返回用户输入;
}否则{
log(`Sorry!但是${userInput}在血腥的石头、布、剪刀运动中是非法武器!`)
}
}
常量getComputerChoice=()=>{
const ranNum=Math.floor(Math.random()*3);
开关(ranNum){
案例0:
返回“岩石”;
案例1:
返回“文件”;
案例2:
返回“剪刀”;
}
};
常量determineWinner=(getUserChoice,getComputerChoice)=>{
if(getComputerChoice==getUserChoice){
log(“这似乎是一个平局!你们的才智不相上下!”);
}
如果(getUserChoice==“rock”){
如果(getComputerChoice==“纸张”){
return“电脑赢了!它已经把你的武器包装好了。”;
}否则{
return“你打败了电脑!他们马上开始制作更大的剪刀。”;
}
}
如果(getUserChoice==“纸张”){
如果(getComputerChoice==“剪刀”){
return“电脑赢了!他们要求艺术和手工艺时间作为奖励。”
}否则{
return“你打败了电脑!他们的小石头根本比不上你的纸飞机!”
}
}
如果(getUserChoice==“剪刀”){
如果(getComputerChoice==“rock”){
return“电脑赢了!你不可能很快就能切直线…”
}否则{
return“你打败了电脑!你破坏了他们机器人孩子的画,造成了情感伤害。你是个怪物。”
}
}
如果(getUserChoice==“枪”){
如果(getComputerChoice==“石头”| | getComputerChoice===“纸”| | getComputerChoice===“剪刀”){
return“你赢了,但代价是什么?”
}
}
if(getUserChoice==未定义){
return“当你准备认真对待这场比赛时,请回来。”
}
}
//在下面的getUserChoice括号中输入您的选择
康斯特游戏=()=>{
让userChoice=getUserChoice(“rock”);
让computerChoice=getComputerChoice();
if(userChoice!==未定义){
log(`您已选择${userChoice}作为您的武器。`);
}
if(userChoice!==未定义){
log(`计算机已将${computerChoice}带入${userChoice}战斗。`);
}
console.log(determineWinner(userChoice,computerChoice))
}

游戏()您应该返回tie消息,而不是记录tie消息,将记录留给调用者:

if (getComputerChoice === getUserChoice) {
  return "It seems it's a tie! You've matched wits!";
}

是的,因为所有其他测试都会返回相应的消息。我的朋友,你绝对是一个传奇人物!谢谢你帮我学习!