Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 7th, 2016, 08:02 AM
Registered User
 
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.
 
Old January 8th, 2016, 02:46 PM
Registered User
 
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.
 
Old January 8th, 2016, 02:47 PM
jmcpeak's Avatar
Wrox Author
 
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 18 Times in 17 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.





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 05:14 PM
hi pls help on this semicolon data [email protected] XML 5 February 20th, 2007 08:09 AM
missing semicolon absolutelymk Access 2 May 5th, 2006 10:10 AM
Missing semicolon? jakeone Access 4 February 15th, 2005 12:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.