Wondering if somebody can explain how the line 'while (foundAtPosition != -1)' in the code below, works.
I understand that it is checking for a condition but don't understand the significance of "not equal to -1" as an escape condition. It has to be something straightforward but I'm beating my head!
var myString= "Welcome to Wrox books.";
myString= myString + "The Wrox website is www.wrox.com .";
myString =myString + "Visit the Wrox website today and thanks for buying Wrox";
// DON'T UNDERSTAND HOW THIS NEXT LINE WORKS
while (foundAtPosition != -1)
foundAtPosition = myString.indexOf("Wrox",foundAtPosition);
if (foundAtPosition != -1)
document.write("There are " + wroxCount + " occurrences of the work Wrox.");