JS rock, paper, scissors program problem

Everything works when tested aside from the ‘paper’ and ‘scissors’. Checked it through but still cant find the issue.
Thanks.

const getUserChoice = (userInput) => {
userInput = userInput.toLowerCase();
if (
userInput === “rock” ||
userInput === “paper” ||
userInput === “scissors”
) {
return userInput;
} else {
console.log(“Error! Please enter rock, paper, or scissors”);
}
};

const getComputerChoice = () => {
Math.floor(Math.random() * 3);
return “rock”, “paper”, “scissors”;
};

const determineWinner = (userChoice, computerChoice) => {
if (userChoice === computerChoice) {
return “The game is a Tie!”;
}

if (userChoice === “rock”) {
if (computerChoice === “paper”) return “Sorry, Computer Won!”;
} else {
return “Congratulations, User Won!”;
}

if (userChoice === “paper”) {
if (computerChoice === “scissors”);
return “Sorry, Computer Won!”;
} else {
return “Congratulations, User Won!”;
}

if (userChoice === “scissors”) {
if (computerChoice === “rock”) {
return “Sorry, Computer Won!”;
} else {
return “Congratulations, User Won!”;
}
}
};

const playGame = () => {
const userChoice = getUserChoice(“rock”);
const computerChoice = getComputerChoice();
console.log(User Choice: ${userChoice});
console.log(Computer Choice: ${computerChoice});
console.log(determineWinner(userChoice, computerChoice));
};

playGame();

I think you didn’t put the else-block inside of the if-block. [The if-else stuff isn’t nested correctly.]

For example, inside the block you have for userChoice being "rock",
the else should be for the computerChoice not being "paper"
( The else should go with the inner if, not the outer if ).

Possible fixes:

you can change
} else {
to be only
else

code
    if (userChoice === "rock") {
        if (computerChoice === "paper") return "Sorry, Computer Won!";
        else return "Congratulations, User Won!";
    }

or you could put in { for the inside if and another } with the last }

code
    if (userChoice === "rock") {
        if (computerChoice === "paper") {
            return "Sorry, Computer Won!";
        } else {
            return "Congratulations, User Won!";
        }
    }

And similarly for the other if-blocks.

Thank you mate. Really appreciate…