Rock-paper-scissors game won't play. Stuck on final step

I am stuck on step 13 in the rock paper scissors project. When I try to console.log(playGame); I receive the response:

[Function: playGame]

Could someone help me figure out what I’m missing??
const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if(userInput ===‘rock’ || userInput === ‘paper’ || userInput ===‘scissors’){
return userInput;
}
else {console.log(‘error’); }
}

const getComputerChoice = () => {

const randomNumber = Math.floor(Math.random() * 3);

switch(randomNumber){
case 0: return ‘rock’;
case 1: return ‘paper’;
case 2: return ‘scissors’;
}

};

const determineWinner = (userChoice, computerChoice) => {
if(userChoice === computerChoice) {
return ‘Tie!’;
}
if(userChoice === ‘rock’) {
if(computerChoice === ‘paper’) {
return ‘Try again!’;
}
else
{return ‘You Win!’;}
}

if(userChoice === ‘paper’) {
if(computerChoice === ‘scissors’ || ‘rock’) {
return ‘Try again!’;
}
else
{return ‘You Win!’;}
}

if(userChoice === ‘scissors’) {
if(computerChoice === ‘rock’) {
return ‘You Win!’;
}
else
{return ‘Try again!’;}
}
}

const playGame = () => {
const userChoice = getUserChoice(‘rock’);

const computerChoice = getComputerChoice();
console.log(‘You chose’ + userChoice);
console.log(‘The computer chose’ + computerChoice);

console.log(determineWinner(userChoice, computerChoice));
};

console.log(playGame);

Hello @angie_marie, welcome to the forums! This is because you are not calling the function when you print it (appending the function name with ()). This is merely printing what type of data playGame is (which is a function):

console.log(someFunction());

vs

console.log(someFunction);

The second one exhibits the same behaviour as your code.

You might want to look at this as well:

The logs the result, but doesn’t return anything. This means you will get undefined after the code in the determineWinner function executes.

I hope this helps!

Figured it out last night! Thank you!

1 Like