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

In a variable after the {}, do you add a semi colon?

I know in a function it isn't necessary but in a variable, is it?

For a variable, yes the semi colon is necessary. It is apart of the JavaScript syntax (computational grammar of the programming language).

on http://www.w3schools.com/js/js_variables.asp you can find a type of examples to further drill this concept into your head.

1 Answer

Hi Victor, Javascript will forgive you if you forget the semicolon, but it is considered good practice to put the semicolon at the end of a statement - in this case assigning value to the variable or declaring a variable.

Tomas