title: How to get Functions output and re-use within IF/else Statement
body: <p>I have <code>function</code> at the bottom of my script which counts for how many tools were used. </p>
  
  <p>Then based on how many tools were used I want to perform different actions. </p>
  
  <p>I can easily check the output of the Function but I struggle to put it into If statement.</p>
  
  <p>How to get Functions output and re-use it within IF Statement?</p>
  
  <pre><code>var HowManyTools = HowManyTools1();
  
  if (HowManyTools &lt;= 2) {
    Category13();
  } else if (HowManyTools &gt;= 6) {
    Category14();
  } else if (HowManyTools &gt; 2) {
    Category12();
  }
  
  function HowManyTools1() {
  //returns value between 1-9
  }
  </code></pre>
  
  <p>Update: I've added <code>if</code> to the last <code>else</code>. It executes the <code>Category13();</code>. Without <code>if</code> all previous statements were simply <code>false</code> so it went straight to the last statement with <code>Category12();</code></p>
  
  <p>I can output into Category13/ Category12. But not the Category14.</p>
  
  <p>It seems like my function can't get defined, as soon as I put it within a variable, and if I try to <code>alert(HowManyTools)</code> I simply get <code>undefined</code> Error. </p>
  
  <p><a href="https://stackoverflow.com/questions/336859/var-functionname-function-vs-function-functionname">Tried a few examples from here but to no avail</a></p>