Help! Rock Paper Scissors


#1


Help me locate my mistake!!!!


https://www.codecademy.com/courses/learn-javascript/projects/rock-paper-scissors


No return for the determineWinner function, the only time anything is returned is if there happens to be a tie then I get "Tie game". Unsure of where my mistake is located within the code.
Rock Paper Scissors project

function determineWinner(userChoice, computerChoice) {
  if (userChoice === computerChoice) {
  return 'Tie Game';
  if (userChoice === 'rock') {
    if (computerChoice === 'paper') {
      return 'The computer won!';
    }else {
      return 'You won!';
    }
  }
  if (userChoice === 'paper') {
    if (computerChoice === "scissors") {
      return ' The computer won!';
    }else{
      return 'You won!';
    }
  }
  if (userChoice === 'scissors') {
    if (computerChoice === 'rock') {
      return 'The computer won!';
    }else{
      return 'You won';
    } 
}
}
}


#2

if (userChoice === computerChoice) {
  return 'Tie Game';
// missing }

see comment, by not closing the if, the comparison of who won is only ran when the result is a tie. But if the result is a tie, there is no winner


#3

I tired closing but then I get "SyntaxError: Syntax error"


#4

i guessed that would happen. locate the } which closed this if clause before, remove it. By just adding a closing curly bracket, you have too many closing curly brackets


#5

thank you very much, I got it corrected.


#6

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