title: Print Triangle using javascript function
body: <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>function makeLine(length) {
    var line = "";
    for (var i = 1; i &lt;= length; i++) {
      for (var j = 1; j &lt;= i; j++) {
        line += "*";
  
      }
  
    }
    return line + "\n";
  }
  console.log(makeLine(2));</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am trying to print triangle, i dont know where i am doing wrong, can some please explain the logic behind printing triangle using nested loops</p>
  
  <pre><code>*
  **
  ***
  </code></pre>