Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 11-11-2005, 01:03 AM   #1
In Runtime
 
outlawstar4761's Avatar
 
Join Date: Jan 2005
Posts: 186
Default JavaScript Help

When using the "indexOf" and "lastIndexOf" operators to count occurences of substrings how can you make JS check for more than one. The example I read only looks for one word. But the one I'm making requires looking for each vowl.

<html>

<script language=JavaScript>

var WooT = prompt("plz enter some text: ")


var foundAtPosition = 0;
var wroxcount = 0;

while (foundAtPosition != -1 )
{
foundAtPosition = WooT.indexOf("A" + "E" + "I" + "O" + "U", foundAtPosition);
if (foundAtPosition != -1)
{
wroxcount++
foundAtPosition++
}
}

document.write("There are " + wroxcount + " occurences of capital vowls");

</script>

There's the code
Thanks
outlawstar4761 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 10:46 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0