Rock, Paper or Scissors /Java

Hi!

Could someone help me with my code, please? Every time I run it, it states:
“The user won! [how it should]
undefined”

It’s probably some kind of syntax error, but I can’t find where ‘undefined’ is coming from.

const getUserChoice = userInput => {
userInput = userInput.toLowerCase();

if (userInput===‘rock’|| userInput===‘paper’ || userInput===‘scissors’
|| userInput===‘bomb’) {
return userInput;}
else {
console.log(‘Please choose between rock, paper, scissors.’) ;}
};

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===‘bomb’) {
return console.log(‘The user won!’);
}

if (userChoice===computerChoice) {
return console.log (‘The game is tie’);}

if (userChoice===‘rock’) {
if (computerChoice===‘paper’){
console.log(‘Computer won!’);
}
else {console.log(‘The User won!’);
}
}

if (userChoice===‘paper’){
if (computerChoice===‘scissors’){
console.log(‘Computer won!’);
}
else {console.log (‘The User won!’);
}
}

if (userChoice===‘scissors’) {
if (computerChoice===‘rock’) {
console.log(‘Computer won!’);
}
else {console.log(‘The User won!’);
}
}
};

const playGame = () => {
const userChoice = getUserChoice (‘bomb’);
const computerChoice = getComputerChoice();

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

playGame ();

Hi,

Functions return value types (such as int, string etc), and if they don’t they return undefined (void functions). When you print a function call, you are printing whatever that function returns. If your function doesn’t return anything, it will print undefined.

So check your code to see if you console.log any function that doesn’t have a return value. Then just remove the console.log.