Computer choice Part 2


#1


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

There was a problem with yor syntax


var userChoice = prompt("Do you choose Rock, Paper, Scissors or Rope?");
var computerChoice = Math.random();
console.log(computerChoice);
    
    
  if (computerChoice >0 && computerChoice <0.33) {
    (computerChoice = "Rock");
   
    };
    
    else if(computerChoice > 0.34 && computerChoice <0.66) {
	computerChoice = "paper";

	
    };
    
 else (computerChoice > 0.67 && computerChoice <=1) {
    (computerChoice = "Scissors");
 
    };


#2

you dont have to put semicolon in the if/else if/else statement


#3

even if it removed also, the same error showing


#4

var userChoice = prompt("Do you choose Rock, Paper, Scissors or Rope?");
var computerChoice = Math.random();
console.log(computerChoice);

if (computerChoice >0 && computerChoice <0.33) {
(computerChoice = "Rock");

};

else if(computerChoice > 0.34 && computerChoice <0.66) {
computerChoice = "paper";


};

else (computerChoice > 0.67 && computerChoice <=1) {
(computerChoice = "Scissors");

};

this is my code..please help..showing syntax error


#5

you should remove the parenthesis and it should look like this -- computerChoice ="rock";

also remove the equal sign between < and 1, and the semicolon in the bracket.

It should look like this

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


#6

thank you! it resolved


#7

Mine looks just like that but it says < is an unexpected token... What am I doing wrong..?


#8

TRY THIS
var userChoice = prompt("Do you choose rock, paper or scissors?");
computerChoice = Math.random();
console.log(computerChoice) ;
if (computerChoice >0 && computerChoice <0.33)
(computerChoice = "Rock");

else if(computerChoice > 0.34 && computerChoice <0.66)
computerChoice = "paper";

else (computerChoice > 0.67 && computerChoice <=1)
(computerChoice = "Scissors");