title: Call a function from an if-statement inside a function
body: <p>I have a function with an if-statement that in turn should call an outside function whether or not something is true. The result I get is 'undefined'. Could you please point me in the right direction?</p>
  
  <p>Function 1:</p>
  
  <pre><code>function printRange(rangeStart, rangeStop) {
      let summa = [];
  
      for (i = rangeStart; i &lt;= rangeStop; i++) {
          summa.push(i);
      }
      let result2 = summa.join();
      return result2;
  }
  </code></pre>
  
  <p>Function 2:</p>
  
  <pre><code>function printRangeReversed(rangeStart, rangeStop) {
      let summa = [];
  
      for (i = rangeStart; i &gt;= rangeStop; i--) {
          summa.push(i);
      }
      let result3 = summa.join();
      return result3;
  }
  </code></pre>
  
  <p>Function 3:</p>
  
  <pre><code>function printAnyRange(rangeStart, rangeStop) {
  
      if (rangeStart &lt; rangeStop) {
          printRange(rangeStart, rangeStop);
      } else {
          printRangeReversed(rangeStart, rangeStop);
      }
      return;
  }
  </code></pre>
  
  <p>Calling the function: <code>printAnyRange(21, 45);</code></p>
  
  <p>As I said it all looks logical to me but I guess it isn't since I get the 'undefined'.</p>
  
  <p>Expected result should be: <code>"21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45"</code></p>
  
  <p>Regards.</p>