5. Both Choices are the Same code not working


#1

Hi,

I have the following code for part 5 of this section:

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

When I run the code, it gives me the folowing error:

"Your compare function does not return 'The result is a tie!' when there is a tie.'"

I don't see how. When I clicked on the hints, I tried copying the exact code from there into my editor, which was the same as what I had typed but for one space, and it still doesn't work... Any help would be much appreciated, thankyou!


#2

SOLVED

I left out an exclamation point as the last character in the string that is returned. This is a great website, but I hate how picky it is over punctuation in the strings. I get that it has to be picky about syntax within the code, but do we have to care whether an exclamation point is included...


#3

It's just that Codecademy is really picky about this stuff. There's a lot of people that get it wrong like that. One time I was stuck because I forgot to put another period in J.K. Rowling. :smiley:


#4

What does the fixed code look like? I am having the same issue...


#5

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

It was just that I left out the exclamation mark at the end of the String.