Javascript examples for Array Operation:Array Element
Check string with an array
<html> <head></head> <body> <script> var text = ["Joe", "a", "v", "Joe", "Joe", "xx"]; var myName = "Joe"; var hits = [];/*from w w w. j a v a 2 s .c om*/ for(var i = 0; i < text.length; i++) { if (text[i] === myName) { hits.push(text[i]); } } console.log(hits); </script> </body> </html>