Scissors, paper,rock_sytaxError

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

const getComputerChoice = () => {
 let num = Math.floor(Math.random()*3); 
  switch (num){
     case 0:
     return 'rock';
     break;
     case 1:
     return 'paper';
     break;
     case 2:
     return 'scissors';
     break;
  }
}

const determineWinner = (userChoice,computerChoice) => {
  if (userChoice === computerChoice){
    retun 'tie!';
  }
  if (userChoice === 'paper'){
    let computerChoice = 'sicssor'
    computerChoice === 'sicssor'? return 'lose' : return 'win';
  }
  if(userChoice === 'sicssor'){
    let computerChoice = 'rock'
    computerChoice === 'rock'? return 'lose' : return 'win';
  }
};

console.log(etermineWinner('rock','paper'))

I try to use ternary operator in the determindWinner function. but it shows:
computerChoice === ‘sicssor’? return ‘lose’ : return ‘win’;
SyntaxError: Unexpected token return
I am wondering it is wrong I use ternary operator there or?

Hey @caryyoung0000790035 , I formatted your code. Go ahead and check out this post as a reference on how to do this.

1 Like

Here is the MDN about ternary operators. It has very useful information.

2 Likes