In need of clarification

I have this code which works fine as it is

const getUserChoice = userInput => {
  userInput = userInput.toLowerCase();
  if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors'){
    return userInput;
  } else {
    console.log('Error. Wrong input!')
  }
}

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 = (getUserChoice, getComputerChoice) => {
  if (getUserChoice === getComputerChoice) {
    return 'The game was a tie!';
  }
  if (getUserChoice === 'rock') {
    if (getComputerChoice === 'paper') {
      return 'Sorry the computer won!';
    } else {
      return 'Congratulations you won!';
    }
  }
}

console.log(determineWinner('rock', 'rock'));

However, Iā€™m not understanding why I need the getComputerChoice function with random numbers if I am declaring the parameter when calling the determineWinner function.

The project can be found in the JavaScript Fullstack course, in the function module.

The goal of the project is to have the computerGuess to be random. So you can call determineWinner with your own guess and a random computer one and see who wins.

For example:

let userChoice = 'rock'
let computerChoice = getComputerChoice();

console.log(`User Choice: ${userChoice}`);
console.log(`Computer Choice: ${computerChoice}`);
console.log(`Outcome: ${determineWinner(userChoice, computerChoice)}`);
1 Like