Need help Rock paper scissors step 7

Need help. I cannot find a useful piece of code to compare mine to, I cannot stream where I am to watch the walkthrough video, and after a couple of hours a day for two days I cannot find my problem.

const getUserChoice = userInput => {
  userInput = userInput.toLowerCase();
  if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors'){
    return userInput;
  } else { 
    console.log (userInput + ' Is not a valid choice.');
  }
};

console.log('You threw ' + getUserChoice('ROCK')); //testing getUserChoice

function getComputerChoice() {
  switch (Math.floor(Math.random()*3)){
    case 0:
    return 'rock';
    case 1:
    return 'paper';
    case 2:
    return 'scissors';
  }
}

console.log('The computer threw '+ getComputerChoice()); //testing getComputerChoice

let chickenDinner = determineWinner => { 
  if (getUserChoice === getComputerChoice) {
    return 'The Game is a tie!'
  }
  else {
   return 'If they both match you have an error.'
  }
};
console.log(chickenDinner());//testing determineWinner
//console.log(valueOf()determineWinner)
1 Like

You need to save the results of getUserChoice('ROCK') and getComputerChoice() to variables, and then use the variables in your chickenDinner function. For example:
instead of:

console.log('You threw ' + getUserChoice('ROCK'));

try:

const userChoice = getUserChoice('ROCK');
console.log('You threw ' + userChoice);

Do the same with the computer’s choice. Then use the variables in your chickenDinner function. Your current if() statement in thechickenDinner function isn’t comparing the results of calling either function.

3 Likes

Thanks, that is exactly where I was lost.

3 Likes