title: What is the functionality of the while loop inside the if statement? JavaScript
body: <p>Below is a function that returns the prime factors of a given number in JavaScript.
  I did not write the function but have been studying it to extend my programming knowledge.</p>
  
  <p>My questions are about the while loop that is inside the following if statement.</p>
  
  <pre><code>if(num % x){
      x = 3; 
      while((num % x) &amp;&amp; ((x = x+2) &lt; root));
  }
  </code></pre>
  
  <p>Questions</p>
  
  <ol>
  <li>What is the purpose of a while loop if there is no code after it?</li>
  <li>What is happening when the while loop evaluates true?</li>
  <li>What is happening when the while loop evaluates false?</li>
  </ol>
  
  <p>Here is the function in it's entirety.</p>
  
  <pre><code>function getPrimeFactors(num){
      num = Math.floor(num);
      var root = 0;
      var factors = [];
      var doLoop = 1 &lt; num;
      var x = 0;
  
      while(doLoop){
          root = Math.sqrt(num);
          x = 2;
  
          if(num % x){
              x = 3;
              while((num % x) &amp;&amp; ((x = x+2) &lt; root));
          }
  
          if(x &gt; root){
              x = num;
          }else{
              x = x;
          }
  
          factors.push(x);
  
          doLoop = (x != num);
  
          num = num/x;
      }
  
      return factors;
  }
  </code></pre>
  
  <p>Thanks for the help!!!</p>