Can someone tell me why my code isn’t working?! I’m so confused!!! It just puts [Function: playGame] at the end when I try to put console.log it.
Since you log the result of the playGame function inside its body rather than returning it, you don’t need to log the return value of the function call of playGame as there is none. But you do need to call the function playGame. In line 56 write playGame()
rather than console.log(playGame);
Hi, few problems with your code:
- on line 56 when you want to call the function playGame(), just call it instead of console.log(playGame), which just logs the function into console.
- on line 48, userChoice(‘paper’) is not a declared function, you may use const userChoice = getUserChoice(), which is a function you created earlier.
- on line 49, same problem as above, use const computerChoice = getComputerChoice(), because this is the function that you created earlier.
I recently learned a tip that is really useful: look at the errors and try to understand the errors will benefit significantly for your learning.
Wish this helps
Nice one. Keep up, but there are few errors in your code.
The forum post discusses an issue with the “Rock, Paper, Scissors” game code, where the function is not working as expected. Key errors include calling userChoice and computerChoice functions incorrectly, and logging the function itself instead of executing it. Users suggest fixing the function calls and correcting syntax errors to make the game run properly.
Please stop posting CGPT replies. They aren’t helpful and they violate Community Guidelines.