Returning objects in Javascript
<p>I have the following variable:</p>

<pre><code>var tags = [{name:'Bold', key:'b'}, { name: 'Italic', key:'i'}]
</code></pre>

<p>Then, in order to get the correct tag I am working on I built a function:</p>

<pre><code>function getCurrentTag(tagType) {
    $.each(tags, function() {
        if (tagType==this.name) {
            return this;
        }
    });
}
</code></pre>

<p>And in the main scope I call it:</p>

<pre><code>currentTag = getCurrentTag('Bold');
</code></pre>

<p>But currentTag is always "undefined".</p>

<p>How can I fix this?</p>

<p>Gidi</p>
