JQuery returns false after return true? : <p>I'm little confused by behaviour of my functions in <code>JQuery</code>. The thing is that <code>is_airport</code> function decides, whether the location is an airport using JSON of airports. </p>

<p>Everything seems to work correctly, JSON is correctly parsed etc. As you can see there is a loop which is used for detecting, whether the <code>destination_id</code> is in airports JSON keys. It is. <strong>It alerts 'OK'</strong> but returns <code>false</code> instead of <code>true</code>. </p>

<p>If there was an <code>AJAX</code> instead of <code>each</code> function, I would expect this behaviour because of async. But why it happens here?</p>

<pre><code>function is_airport(destination_id){
    var json_storage = $("#locations-json");
    var airports = JSON.parse(json_storage.attr("data-airports"));
    $.each(airports,function(id,name){
        console.log(id,destination_id,name);
        if (id==destination_id){
            alert('ok');
            return true
        }
    });
    return false
}

$(document).ready(function () {
    console.log(is_airport(5));)}
</code></pre>

<p>Do you know where is the problem?</p>
