const getuserChoice = userchoice => {
userInput = userInput.toLowerCase();
if(userInput === ‘rock’ || userInput === ‘paper’ || userInput === ‘scissors’) {
return userInput
} else {
return ‘Error, please type: rock, paper or scissors.’;
}
}
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 ‘this game is a tie’
if (userChoice === ‘rock’) {
if (computerChoice === ‘paper’)
return ‘sorry computer won’;
} else {
return ‘congratulation you won’;
if (computerChoice === ‘scissors’) {
if (computerChoice === ‘rock’)
return ‘sorry computer won’;
} else {
return ‘congratulations you won’;
};
cosole.log(determineWinner(‘paper,scissors’));
console.log(determineWinner(‘paper,paper’));
console.log(determineWinner(‘paper,rock’));