RSS

Split the string in to array and tune for prefix – Javascript

04 Mar

Hi folks,

This post is continuation of my previous post. This post is same as the precious post but this will helps to split the given string in to an array object and search for the prefix from each word using Javascript.

Below is the working code.

<html>
<script >
window.onload = function() {
var icName = “ICName icJava”;
var icNameList = icName.split(” “);
for(var i =0; i < icNameList.length;i++){
var spiltICName = icNameList[i];
if(icNameList[i].substring(0,2) == ‘IC’){
alert(‘2 items found’);
}
}
}
</script>
<body>
</body>
</html>

Hope this will save your time for some extent.

Happy Coding!.

Get glued to know more updates.

Have a nice day 🙂

Advertisements
 
Leave a comment

Posted by on March 4, 2013 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: