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 trialAnonymous User
Courses Plus Student 2,703 PointsIs there a reason we say 'let green;' or 'let randomRGB'? Is this another way of writing an empty string??
I'm a little confused by this. At the beginning of the script, where it says: let red; let green; let blue; let randomRGB;
Are these all ways of essentially just declaring empty strings? What is the purpose? Thats the only part that really threw me off in this section.
1 Answer
Steven Parker
231,172 PointsThese variables are being declared, but not assigned. They don't currently have any value, not even an empty string. They will get assigned later.
Declaring a variable defines its scope and makes it available for use in the program.
Anonymous User
Courses Plus Student 2,703 PointsAnonymous User
Courses Plus Student 2,703 PointsThank you so much! This helps a lot!
Laura Dangler
3,301 PointsLaura Dangler
3,301 PointsOkay , so why can't you just declare the variables inside the for loop? Can you explain this to me please?
Steven Parker
231,172 PointsSteven Parker
231,172 PointsYou could declare all but
html
inside the loop, but that would cause them to be created and then disposed for each pass. Declaring them just once allows them to be re-used in the loop passes.