I reviewed the entire section again, ensuring I didn’t misread or misunderstand anything. But still, I’m unable to make the game progress beyond the second block, and I’m completely stumped. Your assistance would be greatly appreciated.
console.log(‘hi’);
//user input for game
const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (getUserChoice === ‘rock’ || getUserChoice === ‘paper’ || getUserChoice === ‘scissors’){
return getUserChoice
} else {
return(‘Error please choose rock, paper, or scissors. Thank you.’);
}
}
//computer input for game
const getComputerChoice = Math.floor(Math.random() * 3);
switch(getComputerChoice) {
case 0:
console.log(‘rock’);
break;
case 1:
console.log(‘paper’);
break;
case 2:
console.log(‘scissors’);
break;
}
// section is to pick a winner
function determineWinner(userChoice, computerChoice) {
if (userChoice === computerChoice) {
return ‘Game is a tie!’;
}
if (userChoice === ‘rock’){
if (computerChoice === ‘paper’)
return ‘The computer has won. Please try again!’;
else {
return ‘Player has won! Congratulations!!’;
}
}
if (userChoice === ‘paper’){
if (computerChoice === ‘rock’){
return ‘The Player has won. Congrataulations!’
}else if (computerChoice === ‘scissors’){
return ‘The coputer has won. Please try again!’;
}
}
if (userChoice === ‘scissors’) {
if( computerChoice === ‘paper’){
return ‘Player has won! Congatulations!’
} else
return ‘The computer has won. Please try again’
}
}
//section starts the game
const playGame = () => {
let getUserChoice = userChoice();
let getComputerChoice = computerchoice ();
console.log(You threw
+ userChoice);
console.log(Computer threw
+ computerChoice);
console.log(determineWinner(userChoice, computerChoice));
}