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

Adding Info Windows

In the video "Adding Info Windows" by Andrew Chalkley which is at http://teamtreehouse.com/library/websites/build-an-interactive-website/customizing-google-maps/adding-info-windows

starting at minate number 0:54, Andrew adds the variable infoWindow but never puts a semicolon (;) at the end of the variable declaration.

Do you not need one there? How come the info window appeared to work at the end of the video?

Many thanks, Drew Butcher

1 Answer

Drew Butcher,

The reason that Andrew's code worked was because technically, semi-colons are optional in JavaScript, although it's not a bad habit to use them syntactically as if they were.

For example, the following JavaScript would work fine without too much (any) trouble:

var a = 3
var b = 2
var c = 1

As I said, my advice would be to get in the habit of using semicolons, even though they are optional, and realize that they are not required by JavaScript.

Hope this helps address your question!

Best,

J.T. Gralka