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!
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
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,545 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!