Hey Lads, all good?
Could someone give me a hand here? I’ve been stuck to this issue for the last two days, I even rewrote the whole code but for some reason it still accuses that the USERCHOICE on the line 42 is not defined, I opened all th hints are given to us and I still can’t see what’s wrong
Follow below the code but I also attached the screenshots.
Thanks a Million
// User’s Turn
const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === ‘rock’ || userInput === ‘paper’ || userInput === ‘scissors’) {
return userInput
} else {
console.log('Error');
}
}
// Computer’s Turn
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;
default:
break;
}
}
// Defining a winner
function determineWinne (userChoice, computerChoice) {
if (userChoice === computerChoice) {
return 'All tied, try again';
}
if (userChoice === ‘rock’) {
if(computerChoice === 'paper') {
return 'Paper, you lost!';
} else {
return 'You won!';
}
}
}
if (userChoice === ‘paper’) {
if(computerChoice === 'scissors') {
return 'Scissors, you lost!';
} else {
return 'You won!';
}
}
if (userChoice === ‘scissors’) {
if (computerChoice === 'rock') {
return 'Rock, you lost!';
} else {
return 'You won!'
}
}
//Playing the Game
const playGame = () => {
const userChoice = getUserChoice('Scissors');
const computerChoice = getComputerChoice();
console.log('You threw: ' + getUserChoice);
console.log('The computer threw: ' + computerChoice);
console.log(determineWinner(userChoice, computerChoice));
};
playGame();