title: In JavaScript; trying to loop adding user input name to a list of names
body: <p>I am trying to update and display a list of names each time the user submits a new name. For example, (first time: "Jim” is displayed, second time: “Jim Bob” is displayed, third time: “Jim Bob Joe” is displayed, etc.) It is required to use closure. I can get the pre-loaded input value, but I guess there is something wrong with my loop and I don't get any further input. Any ideas?</p>
  
  <p>Enter a name and I will add it to the list: </p>
  
  <pre><code>        &lt;input type="text" id="newName" value="Doug"/&gt; 
          &lt;button onclick="closureExample()"&gt;closureExample()&lt;/button&gt;    
          &lt;p id="nameList"&gt;Abe,Bill,Charlie&lt;/p&gt;
          &lt;script&gt;
              var addName = (function () {
                  var names = ['Abe', 'Bill', 'Charlie'];
                  var name = document.getElementById("newName").value;
                  var text;
                  for (var i = 0; i &lt; names.length; i++) {
                      text += names[i];
                  }
                  return function () {return text;}
              })();
  
              function closureExample(){                  
                  document.getElementById("nameList").innerHTML = addName();                  
              }   
          &lt;/script&gt;   
  </code></pre>