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 trialNathalie Agnekil
6,665 PointsWhy are we using strings?
Why are we using string in this? There are no strings printed to the page and .. well.. I just don't understand why in the world we're using strings?! Like this for example: 'rgb(' + red + ',' + green + ',' + blue + ')'
Can someone explain this..?
4 Answers
John Lack-Wilson
8,181 PointsIn this video he is using String's to insert text from JavaScript into a HTML document.
'rgb(' + red + ',' + green + ',' + blue + ')' would be to style a specific element. He's using rgb to define the style, and then concatenating this String with the values he's getting from the red, green and blue variables.
Nathalie Agnekil
6,665 PointsWhere is this string being used?
John Lack-Wilson
8,181 PointsHe is assigning it to the html variable, which will be inserted into the index.html file.
Nathalie Agnekil
6,665 Points"will be"? Cause it's not there now and I get the ten circles with different colors so what does it do?
John Lack-Wilson
8,181 PointsI may be wrong in my assumption here, but it seems like you are thinking that you should see the text displayed on the page somewhere? The text will be inserted into the code of the HTML document. The different colours you are seeing are related to the String that is being passed from JavaScript to HTML.
Nathalie Agnekil
6,665 PointsI thought strings were used to write stuff... I don't really understand the concept of strings then I suppose.
John Lack-Wilson
8,181 PointsYou're partly correct. In this video a String is being used to write the code for the HTML document, in particular it's being used to style the colours of the circles by adding rgb(...).