Rock, Paper, Scissors always comes out a tie

When I run the game, no matter what I put in for a user input it is always returning that the game is a tie. I’ve watched the video and I think my code looks good. Can you find where I went wrong?

const getUserChoice = userInput => {
  userInput = userInput.toLowerCase()
   if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors'){
    return userInput
   } else {
     console.log('error')
   }
};
const getComputerChoice = () => {
  const randomNumber = Math.floor(Math.random() * 3)
    switch (randomNumber) {
      case 0:
      return 'rock'
    break;
      case 1:
      return 'paper'
    break;
      case 2:
      return 'scissors'
    break;
  }
}

const determineWinner = (userChoice, computerChoice) => {
  if (userChoice === computerChoice) {
    return 'Game was 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('rock')
  const computerChoice = getComputerChoice()
  console.log('You threw: ' + userChoice)
  console.log('The computer threw: ' + computerChoice)
  console.log(determineWinner())
};

playGame()

Hi,
you call determineWinner without arguments:

But it expects two arguments. Currently userChoice and computerChoice are undefined.

1 Like