Building Rock Paper Scissors Game


#1



Hi, I am attempting to make a rock, paper, scissors game, but I continue to have a syntax error. Any help is appreciated. Thanks in advance

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

SyntaxError: Unexpected token if


var userChoice = prompt("rock, paper, or scissors?");
var computerChoice = Math.random();
if(computerChoice <=0.37)
{computerChoice = "rock";
}
if(computerChoice <=0.67)
{computerChoice = "paper";}
else {computerChoice = "scissors";}
var game = function(user , computer)
if(user === "scissors") 
{
    if(computer === "rock") {
        console.log("Computer wins!");
    }
    if(computer === "paper") {
        console.log("Player Wins!");
    }
    else {console.log("its a tie!");}
    }
    if(user === "rock")
    {
        if(computer === "scissors"); 
        {
            console.log("Player Wins!");
        }
        if(computer === "paper") 
        {
            console.log("Computer Wins!");
        }
    }
    if(user === "paper")
    {
        if (computer === "rock") 
        {
            console.log("Player Wins!");
        }
        if (computer === "scissors") 
        {
            console.log("Computer Wins!");
        }
    }
    }
game(userChoice, computerChoice)


#2

Remember to use else if

if statements inside if statements is a little tricky at first.
Syntax should look like this:

if (condition) {
  //something1
}
else if (condition) {
  if (condition) {
    //something2
  } 
  else {
    // somethingelse
  }
}

#3

Thanks, I am just getting started, so I really appreciate the help.
Thanks again!