Need help: Rock, Paper, Scissors

Hi,

I’m working on the rock, paper, scissors project:

https://www.codecademy.com/paths/web-development/tracks/getting-started-with-javascript/modules/learn-javascript-functions/projects/rock-paper-scissors-javascript

Got to the end without any problems but when I call playGame() the determineWinner function expression returns ‘undefined’. I keep going over it and can’t see why.

My code is below:

const getUserChoice = userInput => {
  userInput.toLowerCase();
  if(userInput === 'rock' || userInput === 'paper' || userInput === 'scissors'){
    return 'You went for ' + userInput;
     }else{
       console.log('Please enter a valid option. You can use either rock, paper or scissors');
     }
}

//console.log(getUserChoice('scissors'));

function getComputerChoice(){
 let computerChoice = Math.floor(Math.random() * 3);
  if(computerChoice === 1){
    return 'The computer went for rock';
  }else if(computerChoice ===2){
    return 'The computer went for paper';
  }else{
    return 'The computer went for scissors';
  }
}

//console.log(getComputerChoice());

function determineWinner(userChoice, computerChoice){
  if(userChoice === computerChoice){
    return 'It is a tie, try again';
  }
  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(determineWinner('paper', 'rock')); 

const playGame = () =>{
 const userChoice = getUserChoice('rock');
 const computerChoice = getComputerChoice();
  console.log(userChoice);
  console.log(computerChoice);
  console.log(determineWinner(userChoice, computerChoice));
};

playGame();

Hello, @breeds1, and welcome to the forums!

Try adding a console.log() statement inside your determineWinner function like so:

Using console.log() in such a manner is a good way to make observations about what is happening in your code. This should spotlight the problem for you.

Also, I edited your post above, so that your code retains its original formatting. Please review How do I format code in my posts?