I’m hoping someone can help me identify where I went wrong here…I’m getting a syntax error that Identifier userChoice has already been declared
, but I can’t figure out where I declared it?
Here’s a link to the forked project: https://www.codecademy.com/workspaces/623cc7da1adbe1a02ac66587
And the code:
const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors') {
return userInput;
} else {
return 'Error!';
}
}
const getComputerChoice = () => {
const randomNumber = Math.floor(Math.random() * 3);
switch (randomNumber) {
case 0:
return 'rock';
case 1:
return 'paper';
case 2:
return 'scissors';
}}
const determineWinner = (userChoice, computerChoice) => {
if (userChoice === computerChoice) {
return 'Tie!';
}
if (userChoice === 'rock' && computerChoice === 'paper') {
return 'Computer won!';
} else {
return 'User won!';
}
if (userChoice === 'paper' && computerChoice === 'scissors') {
return 'Computer won!'
} else {
return 'User won!'
}
if (userChoice === 'scissors' && computerChoice === 'rock') {
return 'User won!';
} else {
return 'Computer won!'
}
}
const playGame = (userChoice, computerChoice) => {
const userChoice = getUserChoice('scissors');
const computerChoice = getComputerChoice();
console.log('You threw: ' + userChoice);
console.log('The computer threw: ' + computerChoice);
console.log(determineWinner(humanChoice, terminalChoice))
};
playGame();