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!

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


How come in the javascript console you type Math.round(2.2) without a semicolon at the end?

Math objects

1 Answer

28,554 Points

The instructor likely just forgot to include it. In JavaScript (unlike languages like C++, Java or C#) semicolons are not actually mandatory. They are only strictly required if you want to have multiple statements placed on the same line. If you don't have multiple statements on one line then not including a semicolon is completely accepted by JavaScript.

However always using semicolons is considered a standard and good practice. On the console it doesn't really matter since the code isn't going to be saved anywhere anyway, but when writing scripts you should include them.