I need help with lesson 8 of Rock Paper Scissors(invalid Syntax)


#1


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


SyntaxError: Invalid or unexpected token
Oops, try again. There was a problem with your syntax

These error messages keep popping up, and I don't know why

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 "Scissors Wins!";
            }
    } else if(choice1 === "Scissors") {
        if (choice2 === "Rock") {
            return "Rock Wins!";
            } else{
                return "Scissors Wins!";
            }
}
console.log(compare (userChoice, computerChoice));


#2

Your function does not have a closing curly brace.


#3

thanks. it works now


#4

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