Having a little trouble with the rock, paper, scissors project in Learn JavaScript

Hi! I’m having a little trouble with the rock, paper, scissors exercise in Learn JavaScript. I’ve made it through the exercise with no syntax errors, but when I go to “play the game” or the call the playGame() function I’m getting an
error that says “playGame is not defined at Object.” can someone help me understand what is going on here?

It looks like the playGame method is nested inside something else (I can’t tell what because the screenshot doesn’t go up far enough). When you define something inside of something else, you often cannot access it from the outside. So the outer scope where you call playGame() is not aware of the definition you gave it because it is hidden inside of something else.

1 Like

Thanks, Dave! I feel like I’ve scoured this ■■■■ code so many times and can’t figure out where the error is. I’ve narrowed it down to a missing curly bracket, I just can’t figure out which one. Would that cause the nesting error? Here is my code in it’s entirety if you want to give it a peek. Thank you so much for your help!

Update:
I started over, paying extra attention to my syntax, and got it right!
I’m still not sure where my mistake in the first version was though.

hi I need help this is my code a there is a error

const getUserChoice = userInput=> {
userInput = userInput.toLowerCase();
if (userInput === ‘rock’ || userInput === ‘scissors’ || userInput === ‘paper’) {return userInput}
else { console.log(‘Error please type rock paper or scissors’)}
}

const getComputerChoice = () => {
const randomNumber = Math.floor( Math.random() * 3 )}
switch (randomNumber) {
case 0:
return ‘rock’;

case 1
return ‘paper’;

case 2
return ‘scissors’;

}

It looks like
case 1
should be
case 1:
and
case 2
should be
case 2:

1 Like

thank you so much its so helpful