title: javascript absolute beginner = stuck on function returning "undefined"
body: <p>Just for exercise, I'm trying to print out this pattern:</p>
  
  <p><img src="https://i.stack.imgur.com/1KeTR.png" alt="enter image description here"></p>
  
  <p>Here's the code so far:</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 even = "&amp;nbsp;#";
    var odd = "#&amp;nbsp;";
    var size = 4;
    var rowCount = 1;
    var lineLength = 1;
    function writeOdd(size){
     while(lineLength&lt;=size){
      document.write(odd)
      if(lineLength === size){
      document.write("&lt;br&gt;")
      }
      lineLength++;
     }
    }
    function writeEven(size){
     while(lineLength&lt;=size){
      document.write(even)
      if(lineLength === size){
      document.write("&lt;br&gt;")
      }
      lineLength++;
     }
    }  
     if(rowCount &lt;= size &amp;&amp; rowCount % 2 !== 0) {document.write(writeEven(size));}
        else if(rowCount &lt;= size &amp;&amp; rowCount % 2 === 0){document.write(writeOdd(size));}
    rowCount++;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I'm stuck - first line prints out ok, second gives "undefined" and that's it.</p>