title: Why is this prime number generator printing undefined at the end?
body: <p>This is the code I have written which works fine, but the thing is that I am facing this <code>undefined</code> at the end.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var isPrim = function(num) {
    var FG = true
    
    for (let i = 2; i &lt; num; i++) {
      if (num % i == 0) {
        FG = false;
        break;
      }
    }
  
    return FG
  }
  
  var primeNumbers = function(range) {
    for (let i = 3; i &lt;= range; i++) {
      if (isPrim(i)) {
        console.log(i);
      }
    }
  }
  
  console.log(primeNumbers(30));</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is the output in the bowser console:</p>
  
  <p><a href="https://i.stack.imgur.com/j0AHf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j0AHf.png" alt="This is the output in the bowser console"></a></p>