This is my code for Rock,paper, scissors and I keep getting undefined when I console.log(determine winner)
I watched the walkthrough video but I don’t see my error.
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’;
case 1:
return ‘paper’;
case 2:
return ‘scissors’;
}
};
const determineWinner = (getUserChoice,getComputerChoice) => {
if(getUserChoice === getComputerChoice)
return ‘Draw’
}
if (getUserChoice === ‘rock’) {
if(getComputerChoice === ‘paper’) {
return ‘lose’
} else {
return ‘win’;
}
}
if (getUserChoice === ‘paper’) {
if(getComputerChoice === ‘scissors’) {
return ‘lose’
} else {
return ‘win’;
}
}
if (getUserChoice === ‘scissors’) {
if(getComputerChoice === ‘rock’) {
return ‘lose’
} else {
return ‘win’;
}
}
console.log(determineWinner(‘rock’, ‘scissors’));
console.log(determineWinner(‘paper’, ‘rock’));
console.log(determineWinner(‘scissors’, ‘paper’));