Hello everyone Im currently working on the rock paper scissors game. After reaching task 11 we are asked to test our code. How could we test this code if userChoice and computerChoice have not been assigned any values, and nothing yields to them at this point either.
const getUserChoice = userInput => {
userInput = userInput.toLoweCase();
if (userInput === ‘rock’ || userInput === ‘paper’ || userInput === ‘scissors’) {
return userInput;
} else {
console.log(‘Error!’);
}
}
const getComputerChoice = () => {
let randomNumber = Math.floor(Math.random() * 3);
if (randomNumber === 0) {
return ‘rock’;
} else if (randomNumber === 1) {
return ‘paper’;
} else {
return ‘scissors’;
}
}
const determineWinner = (userChoice, computerChoice) => {
if (userChoice === computerChoice) {
return ‘Tie Game’;
} else if (userChoice === ‘rock’ && computerChoice === ‘scissors’) {
return ‘User Wins’;
} else if (userChoice === ‘paper’ && computerChoice === ‘rock’) {
return ‘User Wins’;
} else if (userChoice === ‘scissors’ && computerChoice === ‘paper’) {
return ‘User Wins’;
} else {
return ‘Computer Wins’;
}
}