6. What if choice 1 is rock?


#1


"Oops, try again. There was a problem with your syntax."

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

@javablaster20925

Please be sure to keep nice spacing, just like doing vertical addition in math. That way it becomes easier to see what the problem is :slight_smile:

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

#3

Thanks. I figured it out the problem.


#4

Hi @msfrisby you code has a problem ...his doesn't look welll


#5

@wizmarco I didn't change her code, I only added the spaces. Is that what you mean?


#6

On yours it's missing the closing } of the compare function then look the code of javablaster20925


#7

Wasn't OP missing it too? When I pasted his program in the console I got the missing bracket error notification right away.


#8

so maybe you didn't copy all the code ?


#9

That's weird, I thought I did... But I do see the right number now. What was the solution if I may ask, @javablaster20925?