title: Why does my split string output multiple times using only JavaScript?
body: <p>Let me preface my question by saying that I'm a beginning software engineering student in an Intro to JavaScript course. I'm having an issue with an assignment for the JavaScript course. </p>
  
  <p>Here is the assignment, "Create a file called nameSplit.html that uses one single prompt() call to get a full name from the user--first, middle and last name. Then, split the input into an array and use a loop to output each name on a separate line. For full credit, you must use a loop rather than joining the array back into a string."</p>
  
  <p>My issue is that when I write the split string to the page, it writes the split string multiple times on separate lines which isn't what I want. What I want is for the string to separate and each part to be on a separate line. </p>
  
  <p>Here's my code.</p>
  
  <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>var fullName = prompt("Please enter your full name: first, middle (if you have one), and last name.", "Full Middle Last");
  
  function nameSplit(name) {
    var nameAfterSplit = name.split(" ");
  
    for (i = 0; i &lt; nameAfterSplit.length; i++) {
      document.write(nameAfterSplit + "&lt;br /&gt;");
    }
  }
  nameSplit(fullName);</code></pre>
  </div>
  </div>
  </p>
  
  <p>Can anyone help me with this? </p>