idk why my code doesn’t work. i compared it to an other code from the same objective and didn’t finde any difference
hope you guys can help me
const userChoice = userInput => {
userInput = userInput.toLowerCase();
if (
userInput === “rock” ||
userInput === “paper” ||
userInput === “scissors”
) {
return userInput;
} else {
console.log(“error”);
}
};
console.log(userChoice(“rock”));
const compChoice = () => {
let choice = Math.floor(Math.random() * 3);
return choice === 0 ? ‘rock’ : (choice === 1 ? ‘paper’ : ‘scissors’);
}
}
let theWinner = (compChoice, userChoice) => {
if (compChoice === userChoice) {
return “tie”;
};
if (userChoice === “rock”) {
if (compChoice === “paper”) {
return “comp won”;
} else {
return “you won”;
};
};
if (userChoice === “paper”) {
if (compChoice === “scissors”) {
return “comp won”;
} else {
return “you won”;
};
};
if (userChoice === “scissors”) {
if (compChoice === “rock”) {
return “comp won”;
} else {
return “you won”;
};
};
};
console.log(theWinner(‘paper’, ‘scissors’))