Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAddys Guerra
401 PointsSo it's safe to say by now that when you use the "prompt" method in javascript, it automatically stores the input value?
I don't know if this was explained in a prior video, but it's important to note that you don't need a variable to store an input value when you have prompt, correct?
Thanks
1 Answer
Jason Williams
6,691 PointsIf you wish to use the input and recall it from memory then you'll need a variable to store it in or else you will have no way of accessing the data from memory to my knowledge.
Arikaturika Tumojenko
8,897 PointsArikaturika Tumojenko
8,897 PointsYou need a variable to store an input when you have a prompt box. Otherwise the value is forever lost.
prompt("How many days are in a week?");
(The user types 7 and the number is not stored anywhere. You can't access this value and you can't use it later in your code.)
var weekDays = prompt("How many days are in a week?);
(The user types 7 and the number is stored in the weekDays variable. You can access its value and use it later in your code.)