Ask coding questions

← Back to all posts
JavaScript Inputs
MattyB10 (0)

How do you do inputs in JavaScript? On the internet it says to use a prompt() method but that never works. If you could help that would be great. Thanks.

Answered by GavHern (64) [earned 5 cycles]
View Answer
Vandesm14 (707)

You can use prompt() to get input from the user. To actually persist the data, make sure you store the results into a variable: var userInput = prompt("What is your name?");

Please mark this as answered if I helped your problem 👍

MattyB10 (0)


I tried using the "var userInput..." but it says prompt is not defined. I included the picture below, if it is not accessible let me know. Again thank you so much for the help.