title: While loop to print vowels and other elements on a new line in JavaScript
body: <p>Trying to print any vowels from a word on a new line in the order they appear. 
  Then do the same for each constant after all the vowels have been printed.</p>
  
  <p>I've tried using breaks and a switch case but the code wouldn't work. </p>
  
  <pre><code>function vowelsAndConsonants(s) {
      var atom = s.length;
      var i = 0;
      while (i &lt;= atom)
      {
          if (s[i] === 'a' || s[i] === 'e' || s[i] === 'i' || s[i] === 'o' || s[i] === 'u') {
              console.log('\n' + s[i]);
          }
          else {
              console.log('\n' + s);
          }
      }
  
  }
  </code></pre>
  
  <p>I expect an output to be like:</p>
  
  <pre><code>a
  i
  o
  </code></pre>
  
  <p>Then the consonants in the order they appear:</p>
  
  <pre><code>t
  p
  r
  </code></pre>