Once Again...Rock Paper Scissors Exercise

I honestly have no idea where I am going wrong with this exercise, can someone please take a look at my code and let me know what I’m doing wrong…

const getUserChoice = (userInput) => {
  userInput = userInput.toLowerCase(); 
    if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors'){ 
      return userInput;
  } else {
      console.log ('Please make a valid selection')
    }
  };

const computerChoice = () => {
  const randomNumber =  Math.floor(Math.random() * 3);
  switch(randomNumber) {
    case 0:
      return 'rock';
    case 1:
      return 'paper';
    case 2:
      return 'scissors';
  }
}
console.log(computerChoice());

const determineWinner = (UserChoice, computerChoice) => {
  if(UserChoice === computerChoice){
    return "The game is a tie!"
  	}
  	if(UserChoice === 'rock') {
   	 if(computerChoice === 'paper') {
      return "Computer Won!"
    } else {
      "User Won!"
    }
  } 
  
  if(UserChoice === 'paper') {
    if(computerChoice === 'scissors'){
      return "Computer Won!"
    } else {
      "User Won!"
    }
	}
  
  if(UserChoice === 'scissors') {
    if(computerChoice === 'rock') {
      return "Computer Won!"
    } else {
      "User Won!"
    }
	}
}
console.log(determineWinner(getUserChoice('rock'), computerChoice()));

Hello, @hazelbag. Welcome to the forum.

You should delete this line (it isn’t really doing anything). It gets executed when the program is first run, but then the computer’s choice is assigned again in this line:

Aside from that you’ve got just one problem. Look closely at your else statements. What does this: "User won!" do?

I added that just to determine what happens, however even if removed and add this:

const determineWinner = (UserChoice, computerChoice) => {
  if(UserChoice === computerChoice){
    return "The game is a tie!"
  	}
  	if(UserChoice === 'rock') {
   	 if(computerChoice === 'paper') {
      return "Computer Won!"
    } else {
      "User Won!"
    }
  } 
  
  if(UserChoice === 'paper') {
    if(computerChoice === 'scissors'){
      return "Computer Won!"
    } else {
      "User Won!"
    }
	}
  
  if(UserChoice === 'scissors') {
    if(computerChoice === 'rock') {
      return "Computer Won!"
    } else {
      "User Won!"
    }
	}
}
console.log(determineWinner(getUserChoice('rock'), computerChoice()));

There are some executions that still returns undefined and none that return the “User Won” so I’m not too sure about where my else statement does not get executed in the code or if it even does.

I’m lost on this one…

why is there no return keyword before the "User Won!" string?

So it should then be something like this then:

  if(UserChoice === 'scissors') {
    if(computerChoice === 'rock') {
      return "Computer Won!"
    } else {
      return "User Won!"
    }
	}

Yup! It was missing the return keyword