Symtax error: unexpected token IF: help needed


#1

Below is my code, cannot find what IF statement is wrong, i'm going codeblind! please help

var userChoice = prompt("Would you like to play Rock, Paper, Scissors?");
var computerChoice = Maths.random();

if (computerChoice <= .34 ){
computerChoice = "rock";
} else if (computerChoice <= .67) {
computerChoice = "scissors";
} else {
computerChoice = "paper"};

console.log(computerChoice);

var compare = function(choice1,choice2)
if (choice1 === choice2) {
return "the game 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";
}

else if (choice1 === "scissors")

if (choice2 === "rock") {
return "Rock wins";
} else {
return "Scissors win";
}
}
console.log(compare(userChoice, computerChoice))


#2

Here your bracket should be outside the ;

Writing the computer statement like this makes it look more like a rock paper scissors game console.log("Computer: " + computerChoice);

Here

Your function should take the arguments
userChoice, computerChoice

your main problem is here

You never included an opening bracket. {

and here

Should work after debugging correctly :slight_smile: