I need help at 9/9 , unexpected token {


#1

var userChoice = prompt("Do you choose rock, paper, scissors or rope?");
var computerChoice = Math.random();
if (computerChoice < 0.25) {
computerChoice = "rock";
} else if(computerChoice <= 0.5) {
computerChoice = "paper";
}
if(computerChoice <= 0.75{
computerChoice = "scissors";
} else if(computerChoice <=1.0){
computerChoice = "rope"
}
var compare = function(choice1, choice2) {

if(choice1===choice2){
    return "The result is a tie!";
    console.log(compare(userChoise, computerChoice))
}
else if(choice81==="rock") {
    if(choice2==="scissors") {
        return "rock wins" ;
    }
    else{
        return "paper wins" ;    
    }
}
else if(choice1==="paper"){
    if(choice2==="rock"){
        return "paper wins" ;
    }
    else{
        return "scissors wins" ;  
    }
}
else if(choice1==="scissors"){
    if(choice2==="paper"){
        return "scissors wins" ;
    }
    else{
        return "rock wins" ;
    }
}
else if(choice1==="rope"){
    if(choice2==="rock"){
        return "rope wins" ;
    }
     if(choice2==="paper"){
        return "rope wins" ;
    }
   
    else{
        return "scissors wins" ;  
    }
}

}
console.log(compare(userChoice, computerChoice))


#2

I didn't see anything bad in the code looking it fast, but I should code your if/else blocks like this (sometimes there is the error):

if (..) {
} else {
    if (..) {
    } else {
    }
    # ... and so on.
}

#3

Hi @bitrunner97838

There is some mistakes :

  • Change line 8

if(computerChoice <= 0.75{

in

else if(computerChoice <= 0.75){
  • Change "choice81" in "choice1" (line 19)
  • You have to close your "compare" function

Hold on :wink: