Javascript Search word in String by converting case - Javascript String Operation

Javascript examples for String Operation:String Case

Description

Javascript Search word in String by converting case

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){// ww  w .  j  av a 2  s . co m
var exists = function (content, q) {
    var result = content.split(" ").filter(function(item) {
        return item.toLowerCase() === q.toLowerCase();
    });
    return result.length > 0;
};
var query = "BEsT";
var string = "it is the BEST vest best";
console.log(exists(string, query));
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials