title: How can I get the return value from a function calling another function in javascript/jQuery?
body: <p>So you can assign a value to <code>var doub</code> as below: </p>
  
  <pre><code>function getDouble(number) {
      var doubl = number + number;
      return doubl;
  }
  
  var num = 4;
  var doub = getDouble(num);
  </code></pre>
  
  <p>I want to know if I can get the return type by calling a second function as below. So can the return value of the second method be assigned to <code>doub</code>?</p>
  
  <pre><code>function getDouble(number) {
      var doubl = number + number;
      return quadruple(doubl);
  }
  
  function quadruple(doubl) {
      quad = doubl + doubl
      return quad;
  }
  
  var num = 4;
  var doub = getDouble(num);
  </code></pre>
  
  <p>For some reason it doesn't work for me.</p>
  
  <p>This is my code with the problem..I am doing something similar to the above, but not working:</p>
  
  <p>In my doc ready, I have this code..I want the result to be stored in <strong>newjsn</strong></p>
  
  <pre><code>    $(document).ready(function() 
      {
       var newjsn= DatabaseCategoriesToSelectList(num, 200, 100);
  </code></pre>
  
  <p>My DatabaseCategoriesToSelectList function is :</p>
  
  <pre><code>function DatabaseCategoriesToSelectList(jsn, max, min){
  
      var ddl="&lt;option selected='selected' value='"+min+"'&gt;Select...&lt;/option&gt;";
  
      //load categories from database, and put them into the select drop down.
      $.getJSON(GLOBALURL+'content/plugins/subcategories/getSubcategories.php',             
          function(data, ddl) {
  
              var datas=  jQuery.grep(data, function(element, index){
                  return element.category_id &lt; max &amp;&amp; element.category_id&gt;min; // retain appropriate elements
              });
              for (x=0; x&lt;datas.length; x++){
                  ddl= ddl+"&lt;option value='"+datas[x].category_id+"'data-subcategory='"+datas[x].category_subselect+"'&gt;"+datas[x].category_safe_name+"&lt;/option&gt;";
              }   
              alert (ddl); return runafter(ddl, jsn); 
          });
  
  }
  
  function runafter(ddl, jsn){
      jsn=ddl;
      alert(jsn);
  
      return 500;
  
  }
  </code></pre>
  
  <p>For some reason, the alerts work, but I can't get it to return me the string. I even tried to return a random value of 500, and it doesnt..</p>