Javascript Rock paper scissor

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

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

const determineWinner= (userChoice, computerChoice) => {
    if (userChoice === computerChoice)
    return 'tie'
  } else if (userChoice === 'rock' && computerChoice === 'paper'){
    return 'You lost.'
  } else if (userChoice === 'paper' && computerChoice === 'scissor'){
    return 'You lost.'
  } else if (userChoice === 'scissor' && computerChoice === 'rock'){
    return 'You lost.'
  } else {
    console.log('You Win!');
  }

Morning, is there something wrong with this code? (the error should be on const determineWinner also i’m not following the tutorial, i’m trying a different one

Learn JavaScript Syntax: Functions | Codecademy

Solved. const determineWinner= (userChoice, computerChoice) => {
if (userChoice === computerChoice){
return ‘tie’
} else if (userChoice === ‘rock’ && computerChoice === ‘paper’){
return ‘You lost.’
} else if (userChoice === ‘paper’ && computerChoice === ‘scissor’){
return ‘You lost.’
} else if (userChoice === ‘scissor’ && computerChoice === ‘rock’){
return ‘You lost.’
} else {
console.log(‘You Win!’);
}
}