Array filtering by search query
<p>How to filter an array with an particular search term?
for example-- we have an array 
[Tom Harry,Tom John,John Glen,Tom Harward] When we search for  "Tom H" then only Tom Harry and Tom Harward should be come as output
[Tom Harward,Tom Harry];
Using Javascript </p>

<pre><code>var k=0;
filter=[];
var fc=input.charAt(0);
var sc=input.charAt(1);
for(var i=0;i&lt;array.length;i++)
{
    if(array[i].charAt(0)===fc)
    {
        if(array[i].charAt(1)===sc || sc.charAt(1)=="" )
        {       
            filter[k]=[];
            filter[k]=array[i];
            filter[k]=array[i];
            k++;    
        }
        else
        {
            continue;
        }
    }
    else
    {
        continue;
    }
}
</code></pre>
