Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Amandeep Pasricha14,932 Points
So why isn't it that we needed a specific color for red, blue, and green?
Essentially, I am asking conceptually why he felt the need to remove the red, green, and blue variables at the end. I just would have thought he would have wanted a colour value defined specifically for each.
Eric M11,515 Points
blue variables were originally just used as placeholders for random numbers. Then those numbers were concatenated together into the
The generation of the value for the
rbgColor variable was later replaced with the
randomColor() function, which returns this concatenated value. So the
rbgColor variable no longer got its value from the
blue variables. As such, they did nothing.
There's also the fact that if there is a variable called
red in code, many people will expect it to relate to the colour red. e.g.
rgb(255,0,0) or hex of
#FF0000. Some people might not expect it to be the first portion of an rbg value (although it was somewhat obvious in this case).
The short answer is, those variables were removed because their values were no longer used!