console.log('hi');
const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors' || userInput ==='bomb')
return userInput;
else return console.log("Not a valid choice!");
};
//console.log(getUserChoice("Rock"));
//console.log(getUserChoice("pizza"));
function getComputerChoice() {
number = Math.floor(Math.random() * 3);
if (number === 0)
return 'rock';
else if (number === 1)
return 'paper';
else return 'scissors';
};
//console.log(getComputerChoice());
function determineWinner(userChoice, computerChoice) {
if (userChoice === computerChoice) {
return "Tie!";
}
if (userChoice === 'bomb') {
return "You win!";
}
if (userChoice === 'rock') {
if (computerChoice === 'scissors') {
return 'You win!';
} else {
return 'Computer wins!';
}
}
if (userChoice === 'paper') {
if (computerChoice === 'rock') {
return 'You win!';
} else {
return 'Computer wins!';
}
}
if (userChoice === 'scissors') {
if (computerChoice === 'paper') {
return 'You win!';
} else {
return 'Computer wins!';
}
}
}
//console.log(determineWinner('rock', getComputerChoice()));
function playGame() {
userChoice = getUserChoice('paper');
console.log('You chose: ' + userChoice);
computerChoice = getComputerChoice();
console.log('Computer chose: ' + computerChoice);
console.log(determineWinner(userChoice, computerChoice));
};
playGame()