title: Javascript: Check if function is TRUE
body: <p>i have a function, which should return TRUE, when IF condition inside FOR cyklus is met. (i tested that condition, it works)</p>
  
  <pre><code>createBtn.addEventListener('click',function (e){
  
  var ch = function check(){
  var url = "http://hotel.010.sk/skyfit/read.php";
  var json, poc, vypis;
  var i=0;
  
  var xhr = Ti.Network.createHTTPClient({
      onload: function() {
      json = JSON.parse(this.responseText);
  
  
          for (i = 0; i &lt; json.poc.length; i++) {
  
              prnt = json.poc[i];  
  
              if(win.xtra_id == prnt.id_cv &amp;&amp; picker.getSelectedRow(0).title == prnt.datum &amp;&amp; prnt.capacity &lt;= prnt.cnt ){
  
                  return true;
              }
  
          };
  
      }
  
  });
  
  
  xhr.open("GET", url);
  xhr.send();             
  
  };
  
  ...
  </code></pre>
  
  <p>But when i call function here to check it turns me always <strong>true</strong>, unless IF condition in check() is not met!    </p>
  
  <pre><code>if(ch){
  
  alert('Something');       
  }
  </code></pre>
  
  <p>How to fix my function to get TRUE only when my condition is met?</p>
  
  <p>Thanks.</p>