Could someone help me please!


#1

I have been working on this for quite some time and according to my research it is correct, but it says I have a syntax error. Please help.

/*var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice);*/
var compare = function (choice1,choice2)
{if(choice1===choice2)
    return "The result is a tie!";
}
else if(choice1==="rock"){
    if(choice2==="scissors")
    {
      return "rock wins";
    }
      else 
    {
    return "paper wins";
    }
else if(choice1==="paper"){
    if(choice2==="rock"){
        return "paper wins";}
        else {
        return "rock wins";
    }
}
}


#2

In the hint for this lesson, you are given a format to use for your else if statements:

else if (choice 1 code){
if (choice 2 code)
{ return "something wins"; }
else
{ return "other wins"; }
}

Remember that curly braces wrap around code waiting to execute if a certain condition is present. Make sure all your braces are where they need to be. Check all your conditions.

It might help to input your code into a site like https://repl.it. You'll see exactly what lines the errors in your code are.


#3

My code is according to that rule? Could you be more specific please?


#4

Is a curly brace missing?

Is a curly brace missing?


#5

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