Javascript Rock, Paper, Scissors Lesson

Hi there,

I have successfully created the rock, paper, scissors lesson on Codecademy, but struggling on one last part.

As you can see in the image, the code runs without any errors, but it doesn’t seem to be processing my “getComputerChoice” function. I have also tested my code by giving the ComputerChoice’s answer myself, but it will always tell me I have won, no matter if I draw, lose or win.

I also can’t stop the full code from displaying on the console, which I am not sure on how to fix either.

Here is the GitHub link for my code: https://gist.github.com/cc3aa5929477650ebc79633efcdc7b1b

Any help is much appreciated.

getComputerChoice is a function, so every time you call it you need to call it as a function. Check through your playGame function and see what you can find with that!

1 Like

Hi. Thanks for the help.

Still really quite new to Javascript and haven’t been on Codecademy for a couple of weeks. Can you show me / explain to me what I need to do?

Cheers

This is a function call:

getUserChoice('rock');

This is not a function call:

getUserChoice;

You use both in your playGame() function, and since functions are just objects in JavaScript the latter is why you’re getting the code of your function written to the console.

2 Likes

Thanks for the help, and sorry I keep needing help :stuck_out_tongue:, my console is displaying the right thing now, but it isnt correctly determining the winner.

See screenshots below for an example.

I may get rock on both the user side, and the computer side, but the winner is chosen completely at random, both user, and computer have shown up as winners, along with a tie.

Sorry if I didnt explain it too well.

1 Like

Don’t forget that everything is case sensitive!

I see that you have:
const userChoice = getUserChoice('Rock');

while inside your function you check:
if (userChoice === 'rock')

Notice the typo? You have Rock and then rock

1 Like

Furthermore, in line 57 you are calling:
const computerChoice = getComputerChoice;

Remember that if that’s a function call, it should be getComputerChoice()

Edit:
I just looked more at the code. So in lines 59 and 60 you are correctly calling getComputerChoice(), but that means you aren’t using the const variable you created in line 57, since for that you would just use computerChoice.

1 Like