How can you access the result of a prompt box? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can you access the result of a prompt box?

Hi, I'm just learning JavaScript and I was wondering if there is a way to access what the user inputs into a prompt box and if so, how do you do it?

27th Oct 2017, 10:26 PM
jacksonofgames 28
jacksonofgames 28 - avatar
3 Answers
+ 12
var x = prompt("enter something") console.log(x) // whatever the user inputted is inside x now as a string
27th Oct 2017, 10:36 PM
Burey
Burey - avatar
+ 4
var variable = prompt(text, defaultText); ^That'll store the inputted value into the variable so you can use their inputted data.
27th Oct 2017, 10:36 PM
AgentSmith
+ 1
Thanks guys
28th Oct 2017, 1:08 PM
jacksonofgames 28
jacksonofgames 28 - avatar