title: Understanding use of empty string in Javascript
body: <p>I am taking a Javascript class and we recently had an exercise that I am having a hard time understanding how the solution actually works.  </p>
  
  <p>The question is this: </p>
  
  <p>Create a variable n and assign it an integer.
  Code a while loop that builds as a single string, the numbers 1 through n, separated by commas
  How can we make sure not to have a comma after the last number? e.g., for n = 9 print "1, 2, 3, 4, 5, 6, 7, 8, 9"</p>
  
  <p>I got so far as to be able to list each number with commas but they were not on the same line.  My instructor tried to walk me through the solution but her explanation isn't working for me.  Is there anyone that can explain to me why using a variable with an empty string provides the solution.  This is what she showed me as the correct solution (I am ignoring the not showing last comma part for right now): </p>
  
  <pre><code>var n = 1
  var tr = ""
  
  while (n &lt;= 9) {
  tr = tr + n + "," 
  console.log (tr)
  n++
  }
  </code></pre>
  
  <p>I don't understand how an empty string helps accomplish this outcome. Anyone particularly good at analogies or explaining this logic?</p>