title: Cant figure out how to return the callback function - need alternative solution
body: <p>Im trying to return a callback value after the data is loaded, Im probably looking at this all wrong.</p>
  
  <pre><code>    var loadFromDatabase = function(callback){
    if (!obj.data.myarray) {
        // the problem is here, the jquery obj returns the ajax request obj
      return $.getJSON('http://validjson',function(data){
            obj.data.myarray = data.myarray;
            return callback();
          }); 
        } else {
      return callback();
    }
  };
  var findObjInArray = function(){
        // need i to be returned, but isnt working in the if statement, but works in the else statement
    return loadFromDatabase(function(){
      var l = obj.data.myarray.length;
      for (var i = 0; i &lt; 50;i++) {
        if (i === 30) {
        return i;
          }
    }
      });
    };
    var myval = findObjInArray();
    console.log(myval);
  </code></pre>