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 trialYiChen Chen
5,228 PointsWhat's the different between these two?
rgbColor = 'rgb(' + randomRGB() + ',' + randomRGB() + ',' + randomRGB() + ')';
rgbColor = rgb(randomRGB(), randomRGB() , randomRGB());
1 Answer
jared eiseman
29,023 PointsThe first line sets the value of rgbColor to a string. The second is not a string. Assuming this is going to be used as a style in css, it a) needs to be a string because thats what css is read as. b) the second line just won't work as, if I'm not mistaken, rgb() is not a valid javascript function.
YiChen Chen
5,228 PointsYiChen Chen
5,228 PointsI got it. Thanks.