What's wrong with my conditionals' syntax?


#1

var player1 = prompt("Rock, Paper, or Scissors?");

var compare = function(here) {
if (here === "Rock") {
return "Player 1 wins!";
}
else if (here === "Paper") {
return "Player 1 loses!";
}
else (here === "Scissors") {
return "Its a tie!";
}
}
console.log(compare(player1);

im doing a shorter version of this rock-paper-scissors prompt, assuming that the computer will choose scissors. I can't figure out the syntax however and when I run the code, I get the error: "SyntaxError: Unexpected token {".

Please Help


#2

I'm not sure if the exercise will allow you to make a shorter version without it throwing some reference error.

It looks like your problem is with the end of your function:

You forgot to add a semicolon.


#3

There is a close parentheses missing here.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.