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 trialJenniffer Hernandez
Full Stack JavaScript Techdegree Student 11,662 PointsHello, 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);
Nick Huemmer
Front End Web Development Techdegree Graduate 26,840 PointsIt's interesting that addPatron()
uses a semicolon, while addBook()
doesn't. It can be confusing for those of us new to JavaScript.
2 Answers
Victor Mercier
14,667 PointsYou will not get any error if you donβt put the semicolon.
Clinton Hays
Front End Web Development Techdegree Graduate 18,156 PointsYeah, 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.
Tammi Carter
5,360 PointsTammi Carter
5,360 PointsGood 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