title: Assign Name to Loop
body: <pre><code>//Set the number of spaces in front of text
  numSpaces = 20;
  //
  spaces = "&amp;nbsp";
  //
  importantMessage = "This is a variable message that I will define";
  
  for (var i = 0; i &lt; numSpaces; i++)
  {
  //here is the output on screen
  document.write(spaces)
  }
  
  //printing the full message
  document.write(importantMessage);
  </code></pre>
  
  <p>I'm currently teaching myself javascript. I'm so confused if this is breaking a law in JS land, but how do I define a loop with a name? I would like to give the whole section from for (var...to write(spaces)} a name, so then I can do document.write(nameofloop + importantMessage) which of course will print out what I need. When I do define a name, somehow the loop says "undefined" before the "important message."</p>
  
  <p>Unless there is a better way to loop some html code that is user defined. I want to be able to make a number of spaces before the message on my crawler message and it could vary depending on the user.</p>
  
  <p>I'm confused on multiple { { } } as I will eventually make an if statement once I get this working. Thanks!</p>