title: How to print basic Christmas Tree with JavaScript?
body: <p>Trying to make a simple script that draws a tree of certain height in console with simple JS loops. It should look like that.</p>
  
  <p>For height = 4 :</p>
  
  <pre><code>   *
    ***
   *****
  *******
  </code></pre>
  
  <p>so far have this but somehow it's not working:</p>
  
  <pre><code>function drawTree(height) {
      for ( var i = 0; i &lt; height ; i++ ) {
          var star = '*';
          var space = ' ';
  
          for ( var j = 1; j &lt;= i; j++ ) {
              star = star + '***';            
          }
  
          for ( var k = height - 1 ; k &gt; 0; k-- ) {            
              spacesBefore = space.repeat(k);
              star = spacesBefore + star;
          }
          console.log(star);
      }
  }
  
  var levels = prompt('How many levels high should be the tree?');
  
  drawTree(levels);
  alert('Check console') 
  </code></pre>
  
  <p>any advice where I'm wrong? thx &lt;3</p>