Skip to content
Advertisement

How to store user input using prompt() in JavaScript?

If I were to have a prompt in my code like this:

JavaScript

Is there a way to store the answer?

Advertisement

Answer

Just assign the function call to a variable and don’t forget to perform answer checks

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement