I am facing problem in this?


#1

https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/0/4?curriculum_id=506324b3a7dffd00020bf661

Oops, try again. There was a problem with your syntax.

var userChoice = prompt("Do you choose rock,paper or scissors?");
var computerChoice = Math.random();
console.log(computerChoice());
if(computerChoice 0-0.33)
{
  console.log("rock");
}
else if(computerChoice 0.34-0.66)
{
    console.log("paper");
    }
  else{
      console.log("scissors");
      }


#2

You should change your if statement syntax. After if declaration, the statements in parantheses should return a boolean value. So, change your statement like computerChoice<0.33 or computerChoice > 0.67 etc.


#3

Have a look at this for an explanation


#4

var userChoice = prompt("Do you choose rock,paper or scissors?");
var computerChoice = Math.random();
console.log(computerChoice());
if(0 > computerChoice <0.33)
{
console.log("rock");
}
else if(0.34 >computerChoice< 0.66)
{
console.log("paper");
}
else(0.67> computerChoice < 1)
{
console.log("scissors");
}

now what is wrong with it?
https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/0/4?curriculum_id=506324b3a7dffd00020bf661#


#5

0.34 >computerChoice< 0.66 and 0.67> computerChoice < 1 do not return a boolean value. Just change first one as `computerChoice<0.66` and delete second one (because there is no if statement here, this is else!).


#6

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

console.log(computerChoice);

if (computerChoice = 0-0.33) {
console.log("rock");
}
else if (computerChoice = 0.34-0.66) {
console.log("paper");
}
else if (computerChoice = 0.67-1) {
console.log("scissors");
};


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.