It is giving me a syntax error of });
const getUserChoice = (userInput) => {
userInput = userInput.toLowerCase();
if (userInput === 'rock ' || userInput === 'paper' || userInput === 'scissors') {
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 'paper';
break
case 2:
return 'scissors';
break
}
};
const determineWinner = (userChoice, computerChoice) => {
if (userChoice === computerChoice) {
return 'Tie';
}
if (userChoice === 'rock') {
if (computerChoice === 'paper') {
return 'computer won';
} else {
return 'you win';
}
}
if (userChoice === 'paper') {
if (computerChoice === 'scissors') {
return 'computer won';
} else {
return 'you win';
}
}
if (userChoice === 'scissors') {
if (computerChoice === 'rock') {
return 'computer won';
} else {
return 'you win';
}
};
const playGame = () => {
const userChoice = getUserChoice('rock');
const computerChoice = getComputerChoice();
console.log(userChoice);
console.log(computerChoice);
console.log(determineWinner(userChoice, computerChoice));
};
playGame()