简单的猜拳游戏,请问错误在哪?

varuserchoice=prompt("pleasechooseRockPaperorScissor!");
varpcchoice=Math.random();
switch(pcchoice){
case(pcchoice<=0.33):
pcchoice='rock';
break;
case(pcchoice>0.33&&pcchoice<=0.66):
pcchoice='paper';
break;
default:
pcchoice='scissor';
}
functionrockGame(userchoice){
console.log(userchoice);
console.log(pcchoice);
if(userchoice===pcchoice){
console.log('Tie!');
}elseif(userchoice==='rock'){
if(pcchoice==='scissor'){
console.log('Youwin!');
}else{
console.log('PCwin!');
}
}elseif(userchoice==='scissor'){
if(pcchoice==='paper'){
console.log('Youwin!');
}else{
console.log('PCwin!');
}
}elseif(userchoice==='paper'){
if(pcchoice==='rock'){
console.log('Youwin!');
}else{
console.log('PCwin!');
}
}else{
console.log('输入错误!');
}
}
rockGame();
holdtom
浏览 364回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript