Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed JavaScript Quickstart!
You have completed JavaScript Quickstart!
Preview
Let's use variables together with prompt() and alert() to create a simple program that asks the user for their name and replies with a short message that displays their name.
Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
I'll use variable together
with the prompt and
0:00
alert to create a simple program
that ask the user for their name and
0:01
replies with a short message
that displays their name.
0:04
So in a console, I create a new
variable named response to store and
0:08
remember the response, or what a user
types into the prompt dialogue box.
0:14
So I'll set the value to prompt,
passing it the variable question.
0:19
Now I'll press Shift+Enter
to bring the cursor down.
0:25
And below the response variable,
I'll add alert and
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up