Rock, Paper, Scissors

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’))

You have an extra stray closing brace }

const compChoice = () => {
let choice = Math.floor(Math.random() * 3);
return choice === 0 ? ‘rock’ : (choice === 1 ? ‘paper’ : ‘scissors’);
}
}  // <------- This should be deleted
2 Likes

lol, I knew I got the code right but something isn’t in the right spot. Thank you. In the past hour I rewrited everything and it worked and I solved the lesson.