javascripts arrays
<p>I am playing with my friends on internet</p>

<p>we ask each other to say ( name, or animal, or inanimate) begins with a particular letter</p>

<p>So I am thinking about building a page to help me in training about this game</p>

<p>This is an php code for example:</p>

<pre><code>function getNamesByChars($chars,$type='name'){
    $names=array(
    'd'=&gt;'Dan',
    'j'=&gt;'John',
    );
    $animals=array(
    'd'=&gt;'Dog',
    'j'=&gt;'Jar',
    );

    $chars=explode(' ',$chars);    
    foreach($chars as $char){
        //if it a name
        if($type=='name')
        $results.=$names[$char];
        //if it animal
        elseif($type=='animal')
        $results.=$animals[$char];
    }
}
    getNamesByChars('j d','animal');
    //results (Jar dog)
</code></pre>

<p>the problem here that i need to make this page faster as much as possible</p>

<p>PHP requires loading the page</p>

<p>i Think javascript is the faster way</p>

<p>but i am very beginner in javascript so i can't build this function</p>

<p>Any help in building this function in javascript?</p>
