Rock, paper, scissor 5. "compare function doesn't return tie", why is this wrong?


this is my code

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

what am i doing wrong?


Your return-statement
should return "The result is a tie!" ( with an exclamation mark )

Please read
and concentrate on:

  • the creation of the compare function
  • the truth-table
  • the build of the IF ELSE-IF statement structure as part of the compare FUNCTION-BODY
  • the execution of the compare function (keeping in mind that the return statement is used )


wow, i have been banging my head against the wall, trying to figure out why my code wasn't working, and it was that stupid exclamation mark. good eye, thanks for your help!