为什么我的javascript代码在控制台上运行时没有按预期运行?

时间:2015-08-07 15:03:22

标签: javascript

我正在学习javascript,我对它下面的代码有如下描述。

我想声明一个名为computerChoice的变量,并使其等于Math.random();     打印出computerChoice。

If computerChoice is between 0 and 0.33, make computerChoice equal to "rock".
If computerChoice is between 0.34 and 0.66, make computerChoice equal to "paper".
If computerChoice is between 0.67 and 1, make computerChoice equal to "scissors". 

这是我的CODE.NB.当我在控制台上运行它时,它告诉我语法有问题!

var userChoice=prompt("Do you choose rock, paper or scissors?");
var computerChoice=Math.random();

{
   return console.log(computerChoice);
}
if(0<=computerChoice<=0.33)
{
  computerChoice="rock";

}
else if(computerChoice<=0.66)
{
   computerChoice="paper";

}
else
{
   computerChoice="scissors";

};

0 个答案:

没有答案