Rock, Paper or Scissors Project.... playGame() function parameter?

Exercise link:

Why aren’t we adding a parameter to the playGame() function so that we can invoke it as an argument like so?

const playGame = (choice) => {
let userChoice = getUserChoice(choice);
let computerChoice = getComputerChoice();
console.log(You threw: ${userChoice}!);
console.log(The computer threw: ${computerChoice}!);

// Prints to see who won
console.log(determineWinner(userChoice, computerChoice));

// Start the Game

I feel like it makes more sense to call the playGame() function this way ?

It makes sense, but you don’t have to. I you were getting input from the user, you’d probably have it within the function (since the function is meant to, well, play the game). I think the idea with these projects is that you can do it your way; so if you want a parameter, there’s no reason not to.

1 Like