Need help.. cant proceed.. Unexpected end of input


#1


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


I keep getting the "Unexpected end of input" error


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

HI you should add one } at the end for closing the compare function


#3

It worked. Thank you. Why do you need 3 of those to end it though? so it looks like this
}
}
}

I was only doing two because I thought one was to finish the return, and the other was to finish the compare function. Why are there three? If you could explain it to me I would really appreciate it


#4

The first one close the else statement the second the else if statement and the last one the compare function so it's like that

var compare = function(choice1, choice2) {
    ...
    else if (condition) {
        if (condition) {
        
        }/*close the if statement*/
        else {

       }/*close the else statement*/
    } /*close the else if statement*/

} /*close the compate function*/

#5

thank you so much for your help