Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: Beginning JavaScript 5th Edition
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning JavaScript 5th Edition
This is the forum to discuss the Wrox book Beginning JavaScript, 5th Edition by Jeremy McPeak; 978-1-118-90333-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript 5th Edition section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 7th, 2016, 08:02 AM
Registered User
Points: 26, Level: 1
Points: 26, Level: 1 Points: 26, Level: 1 Points: 26, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2016
Posts: 8
Thanks: 2
Thanked 1 Time in 1 Post
Default Ch3. The do..while loop. (no semicolon);

On page 82 there's a do-while loop example.

Quote:
var userAge;
do {
userAge = prompt("Please enter your age","")
} while (isNaN(userAge) == true);
and below the author repeats one more time:

Quote:
userAge = prompt ("Please enter your age","")
There's no semicolon at the end of the statement inside the do {} block. As far as I can remember the author stated that it's considered best to always end any statement with a semicolon although it's not a must in most cases.

Was the omission of ; intentional? It seems so considering that in both the 4th and 5th editions there's no semicolon.
And there's also a repetition of that line below which doesn't contain a semicolon either.
Of course, you might say that it's not even a mistake. I just want to understand whether or not a semicolon was meant. If not - then it's a minor sign of incosistency.
Reply With Quote
  #2 (permalink)  
Old January 8th, 2016, 02:46 PM
Registered User
Points: 45, Level: 1
Points: 45, Level: 1 Points: 45, Level: 1 Points: 45, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2015
Posts: 5
Thanks: 5
Thanked 2 Times in 2 Posts
Default

I think you are right, it should have a semi-colon as far as best practices are concerned, but most interpreters are smart enough to work without a semi-colon there. Still, it should not have been omitted.
Reply With Quote
  #3 (permalink)  
Old January 8th, 2016, 02:47 PM
jmcpeak's Avatar
Wrox Author
Points: 467, Level: 7
Points: 467, Level: 7 Points: 467, Level: 7 Points: 467, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 87
Thanks: 0
Thanked 17 Times in 16 Posts
Default

Even though the semi-colon is missing in the 4th Edition, it is not intentional in the 5th. It's a code sample that I missed. There should be a semi-colon at the end of that statement.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I call to javascript with Semicolon embeded in XSLT? pagis XSLT 1 January 12th, 2009 12:35 AM
splitting up items separated by semicolon Condor76 XSLT 1 March 17th, 2008 06:14 PM
hi pls help on this semicolon data arvind@allfon XML 5 February 20th, 2007 08:09 AM
missing semicolon absolutelymk Access 2 May 5th, 2006 11:10 AM
Missing semicolon? jakeone Access 4 February 15th, 2005 12:26 PM



All times are GMT -4. The time now is 10:30 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.