Search For

String Contains

Flag Hide Line Nos
Flagging a Snippet, takes the snippet to Moderator Attention;

Contains cannot be directly implement in javascript, however the desired result can be obtained using indexOf method

<script type='text/javascript'>
var s = "foo";
if(s.indexOf("oo") != -1){
    document.write("String contains oo");
    document.write("String does not contain oo");
</ script>
Vote! You feel this code is working like charm ? Go a head Login and Press up arrow.
Didn't work ?, press down arrow and let us know the error in comments