Can someone explain why this this for loop prints out this specific pattern?
<p>I thought I had a good understanding of for loops, but now that I have started to try looping patterns with for loops, things have gotten a lot more confusing. For example, I know that the following code will print out: </p>

<p><code>for (var line =  “#”; line.length &lt; 8; line += “#”)</code>
<code>console.log(line);</code></p>

<p>Output will be:</p>

<pre><code>#
##
###
####
#####
######
#######
</code></pre>

<p>This is what I understand so far about this loop:</p>

<ol>
<li>Firstly, the loop is initialized by creating a variable “line” to store the value “#” which is only one character. </li>
<li>Next, “line.length&lt;8” checks that the length of the string stored in the variable “line” is less than 8 characters long. </li>
<li>The third part “line += “#”” updates the value stored in the line variable by adding “#” for each iteration that line.length&lt;8 is true.  </li>
<li>The length of the string (and therefore line.length) is being updated for each iteration of the loop because a “#” value is being added each time. </li>
</ol>

<p>Can someone explain to me why # is being added once, then twice, then three times etc. From the (incorrect) understanding that I have, I keep thinking that it’ll look like:</p>

<pre><code>#1
#2
#3
</code></pre>

<p>etc.</p>