Choice1 is rock?...New coder here


#1



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


The code from if(choice1 === choice2) { to the end is exactly like what is written on the provided hint, yet I keep getting a syntax error with an unexpected end of input. I cannot figure out what I am doing wrong. A little help? Thanks in advance


Replace this line with your code. 
/*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 there Jason,

I've moved the spacing around on your code a little bit. Take a look and let me know if you can see where the unexpected end of input is, and what the expected end of input is:

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

frisby


#3

Make sure any braces you {open get closed}. Spacing your code like frisby has shown will help catch these in the future.

Code on.
Jon


#4

Hi guys,

I cannot see where my mistake is. Anybody who would like to help me out? Its driving me crazy :slight_smile:


#5

Hi all your if, else if and else statement should be inside the function compare

var compare = function(choice1, choice2) { #open the compare function

#here go the if,else if and else statemetn 

} # close the compare function

#6

It worked. Thanks a lot! :slight_smile:

Now that I look at it, it makes sense of course! Amazing to have such a quick response. Keep it up!