Build "Rock, Paper, Scissors" 8/9 problem, console keeps saying "rock wins"


#1

What seems to be the problem here in my code, the console keeps saying that "rock wins". I cant find the problem, help please !

Here is the code:

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

// Computers choise //

var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);

// Games code //

var compare = function (choise1,choise2)
{
if(choise1 === choise2)
{
return "The result is a tie!";
}
// Player chooses rock //

else if (choise1 === "rock") 
{
    if (choise2 === "scissors") {
        return "rock wins"; 
    }
    else {
        return "paper wins";
    }
}

// Player chooses paper //


else if (choise1 === "paper")
{
    if(choise2 === "rock")
    { 
        return "paper wins";
    }
    else
    {
        return "scissors wins";
    }

}

// Player chooses scissors //

else if (choise1 = "scissors")
{
if(choise2 === "rock")
{
return "rock wins";

}
else {
return "scissors wins";
}
}
}
compare(userChoise,computerChoise)


#2

2 problems that I see on a quick glance through.

  1. when you declared your variables you named them:

    userChoice and computerChoice

and when you called them at the end you called them as

compare(userChoise, computerChoise)
  1. your very last } should have a ; after it to look like:

    };

also wouldn't hurt to throw a ; at the end of alling your function

compare(userChoice, computerChoice);

hope this helps