Prompt not allowed in some lessons?


Maybe I’m just getting the syntax wrong on this, but I’d really prefer to practice prompting for user input wherever it would be fitting, rather than constantly hard-coding input into everything I write, but even something as simple as this is giving me a reference error saying that prompt is not defined:

const getUserChoice = userInput =>{
userInput = prompt(“Rock, paper, or scissors?”);
if((userInput === “rock”) || (userInput === “paper”) || (userInput === “scissors”))
return userInput;
console.log(“Invalid choice”);
return userInput;

The code for the entire game works just fine if I assign a value to userInput, I just would rather have the flexibility of asking for a prompt whenever the course is telling me to obtain information from a user.


Hi @faircloud64256,

You’re right about this, I never try to replicate the situation as I’ve passed those lessons. But it’s really great to see you added some extra code to improve the usability, the initiative should be commended. What I can suggest for you is that if you want to try this additional code as your side project, you can copy and paste it in, essentially it’s a online IDE:

The site is I what suggested to another user while facing the same situation too, you may refer:

I’ve come across another user asking about this matter too. This might be the explanation offered:

That said, enjoy tinkering the side-project.


  • You can try add .toLowerCase() to ensure the all inputs by users are in lower caps.
  • You need to think over how to make the prompt show up again if the else condition is fulfilled (There’re a lot of ways doing this differently, hint: while loop/ recursive/ etc)
  • If you have any questions about code in future, it would be great to have a look on how to format code here. Just use the </> symbol to format the code in your post next time.

Have fun coding, cheers! :slight_smile:

Prompt() returns error "prompt is not defined"

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.