title: JS making a function with multiple variable and other function
body: <p>So, I have following js function which by itself will <strong>NOT</strong> make any sense.</p>
  
  <p>I need to have all the variables and functions (such as <code>for</code>) as a separate function that I can call whenever I need:  </p>
  
  <p><strong>Original</strong></p>
  
  <pre><code>function CUSTOM() {
   jQuery(document).on('click', '.rinci_sub', function (e) {
      var something= RMES_CONT(upimg_hold,rinc_cont,upfile_hold);
      var side = "right";     
      var content_total = RINC_INFO(side, gc_current, "now", something);          
      var rmmc_total = RIN_CONTENT(side,content_total,rmmimg);
      for (var i = 0; i &lt; (rup_att_len); i++) {                       
          var rmm_att_name = rupfile[i].substring(rupfile[i].lastIndexOf('/') + 1);   
          var rinc_file = Ab("rinbox_file", upload_dir + rupfile[i], RH("span", "rmmfile chip",  rmm_att_name, ""));                              
          rup_att.push(rinc_file);
      }
    });
  };
  </code></pre>
  
  <p><strong>What I need:</strong></p>
  
  <pre><code>function OTHER(){
      var something= RMES_CONT(upimg_hold,rinc_cont,upfile_hold);
      var side = "right";     
      var content_total = RINC_INFO(side, gc_current, "now", something);          
      var rmmc_total = RIN_CONTENT(side,content_total,rmmimg);
      for (var i = 0; i &lt; (rup_att_len); i++) {                       
          var rmm_att_name = rupfile[i].substring(rupfile[i].lastIndexOf('/') + 1);   
          var rinc_file = Ab("rinbox_file", upload_dir + rupfile[i], RH("span", "rmmfile chip",  rmm_att_name, ""));                              
          rup_att.push(rinc_file);
      }
  }   
  function CUSTOM_1() {
   jQuery(document).on('click', '.rinci_sub', function (e) {
     OTHER();
    });
  };  
  
  function CUSTOM_2() {
   jQuery(document).on('click', '.some_other', function (e) {
     OTHER();
    });
  };  
  </code></pre>
  
  <p>I know in php, it's alot simpler to make function with variables and other functions. But I am having a hard time making this work.</p>
  
  <p>Could someone show me how to achieve this?</p>
  
  <p>Thanks!     </p>