Why my code only prints `rock` in rock paper and scissor code javascript

Hey , why does the player input always come out as rock ? could someone explain to me what is wrong with it?
here is the code : onst getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === ‘paper’ || userInput === ‘rock’ || userInput === ‘scissors’) {
return userInput; } else {
console.log(‘Error!’);
}
}
function getComputerChoice() {
switch(Math.floor(Math.random() * 3)) {
case 0 :
return (‘rock’) ;
case 1 :
return (‘paper’) ;
case 2 :
return (‘scissors’);
}
}
function determineWinner(userChoice , computerChoice) {
if (userChoice === computerChoice) {
return The game was a tie;
}
if (userChoice === ‘rock’ && computerChoice === ‘paper’) {
return The computer has won !;
} else {
return The player has won !;
}
if (userChoice ===‘scissors’ && computerChoice ===‘paper’) {
return ‘The Player has won !’
} else {
return ‘The computer has won !’
}
} ;
function playGame() {
let userChoice=getUserChoice(‘rock’ || ‘paper’ ||‘scissors’);
let computerChoice=getComputerChoice()
console.log('You threw : ’ + userChoice) ;
console.log('The computer threw : ’ + computerChoice);
determineWinner(userChoice , computerChoice) ;
console.log(determineWinner(userChoice , computerChoice ));
};
playGame()

Update . i found out the let userChoice=getUserChoice(‘rock’ || ‘paper’ ||‘scissors’); . but i dont know how to fix it and make it choose all 3 of them instead of just 1

When it reaches this code,
if the user chose rock and the computer chose paper,
the function returns `The computer has won !`
The else means that for anything else,
the function returns `The player has won !`
and since it reached a return, the rest of the function is not executed.
(therefore else is not the correct thing to use there).

Look up nested if-statements. That is the most common way that project has been done.
(if-block [and maybe else] inside another if-block in some places.)

thank you for the help! may i maybe text you later for a little chat. im at the beggining of my journey and i`d really apreciate if you could take some time to explain some concepts to me?

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.