Hi all, I have run into this issue that i really am not sure what it is as I haven’t found any posts about this.
I am completing the JavaScript project Rock Paper Scissors and my output is the exact log of my code instead of the functions being executed.
This is my code:
const getUserChoice = userInput => {
userInput.toLowerCase();
if (
userInput === "rock" ||
userInput === "scissors" ||
userInput === "paper"
) {
return userInput;
} else {
console.log("Error!");
}
};
const getComputerChoice = () => {
const randomNumber = Math.floor(Math.random() * 3);
switch (randomNumber) {
case 0:
return "rock";
break;
case 1:
return "scissors";
break;
case 2:
return "paper";
break;
}
};
const determineWinner = (getUserChoice, getComputerChoice) => {
if (getUserChoice === getComputerChoice) {
return "tie";
}
if (getUserChoice === "rock") {
if (getComputerChoice === "paper") {
return "computer won";
} else {
return "you won";
}
}
if (getUserChoice === "paper") {
if (getComputerChoice === "scissors") {
return "you won";
} else {
return "computer won";
}
}
if (getUserChoice === "scissors") {
if (getComputerChoice === "rock") {
return "computer won";
} else {
return "you won";
}
}
};
const playGame = () => {
const userChoice = getUserChoice("paper");
const computerChoice = getComputerChoice();
console.log("You formed a " + getUserChoice);
console.log("Comuter formed a " + getComputerChoice);
console.log(determineWinner(userChoice, computerChoice));
};
playGame();
Any help is appreciated, I’m sure this is a simple issue that i’m overlooking. Thank you!!