Rock, paper, scissors - Help needed

For the life of me, I cannot figure out what is causing my error. Please help!

const getUserChoice = (UserInput) => {
  userInput = userInput.toLowerCase();
  if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors') {
    return userInput;
} else {
  console.log('Error!');
  }
}

const getComputerChoice = () => {
 const randomNumber = console.log(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 === 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!';
    } 
  }
};
console.log(determinWinner('scissors'));

You have a typo in your console.log line. Double check “determineWinner”

1 Like