This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by kroko goal
over 8 years

where's the mistake please ?

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”); }; };
};

Answer 55eb6934d3292fd6c2000368

2 votes

Permalink

Could you check if this works?

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

};

points
Submitted by vaskaf
over 8 years

1 comments

mrhappy29 over 8 years

It does indeed! I see what I did wrong now, the “else” had to go outside the if statement within the else if statement. Thank you very much!

Answer 55ff5bd5e39efeff1c000020

0 votes

Permalink

Thank you, this worked for me too. The problem was that I was missing one of the closing braces. I think this is how many people might get tripped up by this exercise.

points
Submitted by Fslayer1
over 8 years

Answer 55f2608ad3292f33700001fc

-1 votes

Permalink

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” } } }

points
Submitted by Allen T Gregory
over 8 years