Hey can some one walk me through my own code, console keeps giving me error code but, i cant seem to find the issue.
const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === 'paper' || userInput === 'scissors' || userInput === 'rock') {
return userInput
} else {
return 'Error you have picked an invailded choice please try again'
}
}
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 'The game was a tie';
}
if (userChoice === 'rock') {
if (computerChoice === 'paper') {
return "Sorry, computer won!";
} else {
return "Congratuations, you won!";
}
if (userChoice === 'scissors') {
if (computerChoice === 'rock') {
return "Sorry, computer won!";
} else {
return "Congratuation, you won!";
}
if (userChoice === 'paper') {
if (computerChoice === 'scissors') {
return "Sorry, computer won!";
} else {
return "Congratuation, you won!";
}
}
console.log(determineWinner('paper','rock'));