Hey there! any question in your mind? Ask It Now!.

Popular Categories





How to check a String contains another sub string using JavaScript

+1 vote
145 views
asked in Programming by raman (530 points)
I am trying to verify that a string contains another sub string , Because I am using JavaScript so String.contains() method is not working in this case.
Please help me out on this. Thanks For your help! 

1 Answer

0 votes
answered by monika (2,040 points)
First of all i would like to let know about indexOf() its a method which returns index within the calling String ,When it does not found any value so it returns -1.
For more info of  indexOf()
 
See this code here: 
 
var s = "foo";
alert(s.indexOf("oo") > -1);
I hope you got my point.
 

Related Questions

+4 votes
5 answers 713 views
+1 vote
1 answer 243 views
+2 votes
1 answer 141 views
+3 votes
1 answer 643 views
+2 votes
2 answers 788 views
–1 vote
0 answers 111 views
+6 votes
2 answers 2,240 views
+1 vote
1 answer 85 views
0 votes
1 answer 149 views

Not a Member yet?

Ask to Folks Login

My Account
864 Folks are online
82 members and 782 guest online
Your feedback is highly appreciated