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();