I honestly have no idea where I am going wrong with this exercise, can someone please take a look at my code and let me know what I’m doing wrong…
const getUserChoice = (userInput) => {
userInput = userInput.toLowerCase();
if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors'){
return userInput;
} else {
console.log ('Please make a valid selection')
}
};
const computerChoice = () => {
const randomNumber = Math.floor(Math.random() * 3);
switch(randomNumber) {
case 0:
return 'rock';
case 1:
return 'paper';
case 2:
return 'scissors';
}
}
console.log(computerChoice());
const determineWinner = (UserChoice, computerChoice) => {
if(UserChoice === computerChoice){
return "The game is a tie!"
}
if(UserChoice === 'rock') {
if(computerChoice === 'paper') {
return "Computer Won!"
} else {
"User Won!"
}
}
if(UserChoice === 'paper') {
if(computerChoice === 'scissors'){
return "Computer Won!"
} else {
"User Won!"
}
}
if(UserChoice === 'scissors') {
if(computerChoice === 'rock') {
return "Computer Won!"
} else {
"User Won!"
}
}
}
console.log(determineWinner(getUserChoice('rock'), computerChoice()));