Syntax


#1



Javascript, Build "Rock, Paper, Scissors", Lesson 6


Error message tells me that the syntax is wrong, but I used the same structure as the hint that was given.


/*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";
        }
        
}


#2

Check you brackets. It looks like the compare function does not have a closing brace.


#3

Where would I place the closing brace? I thought the one at the bottom would close the entire function


#4

The one at the bottom is closing the else if. Add one more.

};

to the very end.


#5

It worked! Thank you