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 Practice Object Interaction Starting with Some Methods Solution: Adding Methods to the Library Class

Jenniffer Hernandez
seal-mask
.a{fill-rule:evenodd;}techdegree
Jenniffer Hernandez
Full Stack JavaScript Techdegree Student 11,662 Points

Hello, just wondering if there is a missing semi colon after this.books.push(book);

Hello, just wondering if there is a missing semi colon after this.books.push(book);

Tammi Carter
Tammi Carter
5,360 Points

Good Day Jenniffer, The Semi Colon whether used or not will not really effect the way your code runs, in "MOST" instances, however in my brief experience with coding , I personally find that its easier to read my own code , to better understand where my code breaks are. Some say "Yes Use it" others say "No It's not necessary", I say if your code is accomplishing what you set it out to accomplish use the method that best fits your coding style. Here is some information I found to be a "good 11 min. listen" on the Semi Colon subject topic. Happy Coding Ms. Hernandez. :-)

ASI Guide - How to Use Semicolons in JavaScript https://youtu.be/DiPmHTYWP78

2 Answers

You will not get any error if you don’t put the semicolon.

Yeah, I think this was probably just a typo. Typically, you'll want to end return statements with a semicolon. Often, developers use an extension like Prettier to catch those things. But, Tammi Carter is correct, in this instance it won't affect behavior, but in other cases it might...so it's better to err on the side of caution.