Please Help! else if error


#1


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


ooops try again there was a problem with your syntax


I am new to JavaScript any pointers would be great.
i am stuck on line "else if (choice1 === "Rock") {"

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) {
won = false;
if (choice1 === choice2) {
    
    return "it is a tie, try again";
}
}; 

else if (choice1 === "Rock") {
 if (choice2 === "Scissors") {
        won = true;
        return "Rocks Wins";
    }
    else {
        return "Paper Wins";
    }


#2

This else if needs to be inside the functions brackets. Take the one curly bracket above this code and put it below it.


#3

Thank you for your quick response, i will upgrade my account now as i want a detailed learning plan.


#4

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