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 Basics!
You have completed JavaScript Basics!
Preview
You can change what your program does by adding decision-making to it. Programmers make a program react to different situations using JavaScript conditional statements.
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
Earlier, you built a simple programme
that prompted the user for their name,
0:00
then used the template to interpolate or
build that name into a string.
0:00
You may have noticed what happens if
the user doesn't enter anything into
0:04
the input field.
0:07
For example, in the prompt dialogue,
I'll click OK without entering anything.
0:08
When that happens,
the final message looks a little strange.
0:13
Notice the empty spaces where
the name is supposed to display, or
0:15
what if the user enters
a random string of numbers?
0:20
Well, that doesn't make sense.
0:23
Ideally, we'd check and
make sure that the user entered correct
0:25
information into the input field
before displaying the Hello message.
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