Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional JavaScript for Web Developers 3rd edition
This is the forum to discuss the Wrox book Professional JavaScript for Web Developers, 3rd Edition by Nicholas C Zakas; ISBN: 978-1-1180-2669-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional JavaScript for Web Developers 3rd 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 August 26th, 2013, 10:58 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter-5

In Chapter-5

StringTypeLocationMethodsExample02.htm

var stringValue = "Lorem inpus dolor sit amet, consectetur adipisicing elit";
var positions = new Array();
var pos = stringValue.indexOf("e");

while(pos > -1){
position.push(pos);
Here can't we just say
instead of
pos = stringValue.indexOf("e", pos + 1);

can't we simple use
pos ++;


}
 
Old September 23rd, 2014, 08:52 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2014
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by kpaccess View Post
In Chapter-5

StringTypeLocationMethodsExample02.htm

var stringValue = "Lorem inpus dolor sit amet, consectetur adipisicing elit";
var positions = new Array();
var pos = stringValue.indexOf("e");

while(pos > -1){
position.push(pos);
Here can't we just say
instead of
pos = stringValue.indexOf("e", pos + 1);

can't we simple use
pos ++;


}
The pos variable is not simple moving an index forward, it is specifically moving forward to each match. The line before the one that you want to change takes the value of pos and saves it to an array, because it is the location of one of the matches.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 4 --> Chapter 5 Continuity?? theboffin BOOK: Professional ASP.NET MVC 4 4 July 8th, 2013 03:36 AM
Chapter 6 - Code Download Missing for this Chapter dbaechtel BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 0 August 11th, 2009 11:02 AM
Chapter 2 - End of chapter exercises whizzkid1892 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 30th, 2008 12:02 PM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM





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