I literally copied the code and I'm getting an error (Both choices are the same)


#1

var compare = function(choice1, choice2) {
if(choice1 === choice2) {
return "The result is a tie";
}
};

I'm on the "Both choices are the same!" part and did everything but got a '''Your compare function does not return 'The result is a tie!' when there is a tie.' error. Copied the code from the hint and got the same thing. What am I missing?

PS: Why isn't there an else option? And if there were, how would the brackets look like?
var compare = function(choice1, choice2) {
if(choice1 === choice2) {
return "The result is a tie";
}
else
{
};
};


#2

This:

The result is a tie

is NOT:

The result is a tie!

You didnt type the !

An else is not everytime needed like here. Maybe you will need it in a chapter later


#3

Hi, thank you for your input.

I see what I did wrong. However, the hint lacks the exclamation point as well. In any case, my bad.

Thanks again!


#4

var compare = function(choice1, choice2);
if(choice1 === choice2) {
return "The result is a tie!";
}

I'm having a problem with the same step. Where is my error? "unexpected token"


#5

apparently i needed another pair of {} starting before the if statement.. I have never had to do this before so why do I have to do it here?


#6

I think that your function should be surrounded by the parentheses:
var compare=function(x,y){
if(x===y){
return "The result is a tie!";
}
}

Although you are required to add an else if after the return in the next part (I think).


#7

That makes sense. I must have overlooked that when i reviewed the functions section. Thank you


#8

Ugh so obnoxious, the code they give you in the hint only lacks the "!" - Something that isn't even relevant to coding.