Help with a function return JS Rock, Paper, Scissors

Hi! I’m having trouble with a function and hoping that someone can help me. Whenever I run the code, the output says [Function: getComputerChoice]. I’m not sure what I’m doing wrong. Here is the link to the exercise and the following is the code:

console.log('hi');
const getUserChoice = (userInput) => {
  userInput = userInput.toLowerCase();
  if(userInput === 'rock' || userInput === 'paper' || userInput === 'scissors'){
    return userInput;
  }else{
    console.log('Error')
  }
};

const getComputerChoice = () => {
  const choice = Math.floor(Math.random() * 3);
  if(choice === 0){
    return 'rock';
  } else if(choice === 1){
    return 'paper';
  }else if(choice === 2){
    return 'scissors'
  }
}
console.log(getComputerChoice)

You need the result of calling the function, meaning something that the function returns,
so
getComputerChoice
should be
getComputerChoice()
as the argument for
console.log

Otherwise, it tries to log the function itself, not the value returned from the function.

2 Likes

THANK YOU!! I completely missed that