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 trial

JavaScript

i don't understand the semicolon before the var color can someone explain

function color () {
vsr color = "rgb(" ;
 color += randomRGB() + " , ";

 etc

  etc                + " ) ";

 ``` js

2 Answers

In JavaScript the semi-colon marks the end of a statement. while I don't see one before var color the one after it means, "The statement is finished. (create a variable called color and give it an initial value of "rgb(".) What follows is a new statement."

i c .. i didn't understand

function color () { var color = "rgb(" ;

so kinda like css , but instead "property( " ; ?

the semicolon plays the colon in css kinda ?

i saw this kinda syntax before in books but I don't c very often.. why is this .. or is it just me?