Hi, my code was working fine until I went to test the game and now this error message comes up
Output:
/home/ccuser/workspace/javascript_101_Unit_3_v2/rockPaperScissors.js:2
userInput = userInput.toLowerCase();
My code:
const getUserChoice = (userInput) => {
userInput = userInput.toLowerCase();
if (
userInput === “rock” ||
userInput === “paper” ||
userInput === “scissors”
) {
return userInput;
} else {
console.log(“Error, the 3 options are rock, paper or scissors.”);
}
};
const getComputerChoice = () => {
const randomNumber = Math.floor(Math.random() * 3);
switch (randomNumber) {
case 0:
return “rock”;
break;
case 1:
return “paper”;
break;
case 2:
return “scissors”;
break;
}
}
function determineWinner(userChoice, computerChoice) {
if (userChoice === computerChoice) {
return “Game was a tie!”;
}
if (userChoice === “rock”) {
if (computerChoice === “paper”) {
return “Computer has won!”;
} else {
return “User has won!”;
}
}
if (userChoice === “paper”) {
if (computerChoice === “scissors”) {
return “Computer has won!”;
} else {
return “User has won!”;
}
}
if (userChoice === “scissors”) {
if (computerChoice === “rock”) {
return “Computer has won!”;
} else {
return “User has won!”;
}
}
}
function playGame() {
const userChoice = getUserChoice();
const computerChoice = getComputerChoice();
console.log("You threw " + userChoice);
console.log("The computer threw " + computerChoice);
console.log(determineWinner(userChoice, computerChoice));
}
playGame();