Paper Rock Scissors

Hi, I have just completed the paper, rock, scissors game project, which seems to be working ok…except when I choose scissors and the computer chooses rock, it returns a win for me! Can someone please have a look at my code and see where I have gone wrong please?

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

const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors' || userInput === 'bomb') {
  return userInput;
} else {
  console.log('Error')
};
};
const getComputerChoice = () => {
  const randomNumber = Math.floor(Math.random() * 3)
    switch (randomNumber) {
      case 0:
        return 'rock';
      case 1:
        return 'paper';
     case 2:
       return 'scissors';
    }
};
const determineWinner = (userChoice, computerChoice) => {
  if (userChoice === 'bomb') {
    return 'You won!';
  }
  if (userChoice === computerChoice) {
    return 'The game is a tie';
  }
  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!';
  }
}
const playGame = () => {
  const userChoice = getUserChoice('scissors');
  const computerChoice = getComputerChoice();
  console.log('You threw:' + userChoice);
  console.log('The computer threw:' + computerChoice);
  console.log(determineWinner(userChoice, computerChoice));
};

playGame();

You should review your if/else for paper and scissors, the error seems to come from one of them.
As the indentation of your code is correct (that’s great!), you may found more easily why ‘You won!’ is displayed.

Adding some console.log() at some place to check exactly what the code is doing can help :wink:

Thanks for the reply patmol6, I will give that a try.