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 trial
Jon Schenck
2,028 PointsOptionals
Why would a constant or variable not have a value? What is the point of a constant or variable not having a value?
2 Answers
razmig pulurian
Courses Plus Student 23,889 PointsHi Jon,
Let's assume you have an app. Users can create an account in this app by filling out a special form. User can enter their First Name, Last Name, Email, Age, and Gender.
Let's say you want to make the First Name, Last Name, and Email fields required, but the Age and Gender fields optional. In this case, you would need variables to store Age and Gender, but if the user chooses not to fill out this information, then it would remain as a variable without any value until the user fills it out.
Hope this helps.
Jon Schenck
2,028 PointsGreat real life example. This helped a lot. Thanks!
razmig pulurian
Courses Plus Student 23,889 PointsGlad the explanation helped. Of course, this is a very simple example. There are many more complex example which you will discover as you start to build apps. Good luck, and keep asking questions :)