You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility
When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!
For some reason my code will not accept my function. It keeps saying it is undefined. Its not taking into account the if statements. This is what I percieve the problem to be. I also have the code here on hastebin for viewing.
console.log(
"hello and welcome to the game rock, paper, scissors! Please choose rock, paper, or scissors!"
);
const getUserChoice = (userInput) => {
userInput = userInput.toLowerCase();
if (
userInput === "rock" ||
userInput === "paper" ||
userInput === "scissors"
) {
return userInput;
} else
console.log("Invalid selection. Please choose rock, paper, or scissors");
};
console.log(getUserChoice("rock"));
const getComputerChoice = () => {
console.log(Math.floor(Math.random() * 3));
if (getComputerChoice === 0) {
return "rock";
} else if (getComputerChoice === 1) {
return "paper";
} else {
if (getComputerChoice === 2) {
return "scissors";
}
}
};
console.log(getComputerChoice());