Rock paper scissors

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.

https://www.codecademy.com/courses/introduction-to-javascript/projects/rock-paper-scissors-javascript

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’;
}
}

Given function parameters (userChoice and computerChoice) get there values from arguments at function call, you could call/invoke the function and provide arguments?

simple example:

const greet = (name) => {
   console.log(`greet ${name}`);
}

name has no value, so when i call the function i provide a value:

greet('eddy')

now greet eddy is logged.

Thanks I now see my mistake.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.