"rock, paper, scissors" project javascript course

the :rock, paper scissors" project

Hey everybody,
I need help with my project, i’m kinda frasturated and the walk through video didn’t help me.
I really checked everything and can’t find the bugs.
The problem is when I need to test my code at number 11 task, for example I write console.log(determineWinner(paper, scissors)); ,I recieve that message - "ReferanceError: computerChoice is not defined at determineWinner "
I’ll paste my work here, can someone find my bug? :pray:

const getUserChoice = userInput => {

  userInput = userInput.toLowerCase();

  if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors') {

    return userInput;

  } else {

    console.log('error!');

  }

};

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 'a tie!'

  }; 

  if (userChoice === 'rock') {

    if (computerChoice === 'paper') {

      return 'The computer won!';

    } else {

      return 'You won!';

    }

  };

  if (userChoice === 'paper') {

    if (computerChoice === 'scissors') {

      return 'The computer won!';

    } else {

      return 'You won!';

    }

  };

  if (userChoice === 'scissors') {

    if (computerChoice === 'rock') {

      return 'The computer won!';

    } else {

       return 'You won!';

    }

  };

}

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

If I look at the function declaration/parameter:

const determineWinner = (userChoice, ComputerChoice) => {

I see ComputerChoice (PascalCase) while in the comparisons you use camelCase:

 if (computerChoice === 'paper')
1 Like

It worked
OMG
How i did not see it
thank you very much!
:upside_down_face: