Rock, scissors or paper Project

Hi everyone,

I am stuck with the project Rock scissors, paper ( here is the link: ) .

The error I add the last line is: “determineWinner is not defined
at Object”.

below is my code:

const getUserChoice = userInput => {

userInput = userInput.toLowerCase();

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

} else {return '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 'The game is a tie!';}


if (userChoice === 'rock') { if (computerChoice === 'paper') {return 'Computer Won'} else

{return 'You Won'}


if (userChoice === 'paper') {if (computerChoice === 'scissors') {return 'Computer Won'} else { return 'You Won'}


if (userChoice === 'scissors') {if (computerChoice === 'rock') {return 'Computer Won'}else {return 'You Won'}



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

Two things come to mind: a typo. We could use a search, and see the names of the declaration and call are the same (which they are)

which leaves us with a scope problem. How is the indention of your code? Having good indention makes it easier to determine scope problems.

You nested your determineWinner function with getComputerChoice function, which means determineWinner is not available in the global scope of your program

1 Like

Thanks, it was indeed the intention.