title: Add user input to array // Javascript
body: <p>This is the code I have so far. When the user enters a word into the input box, I want that word to be stored in an array via the <code>Add Word</code> button. Once a number of words have been entered, the user clicks the <code>Process Word</code> button and I want all the words in the array to appear. How would I do this? Also could someone also explain why when nothing is entered into the input box "field is empty" does not appear?</p>
  
  <pre><code>function begin() {
  var word = "List of words";
    var i = returnword.length
  
  if (userinput.length === 0) {
  word = "Field is empty"
  
  }
    document.getElementById('message2').innerHTML = word
    while (i--) {
  
  
  
     document.getElementById('message').innerHTML = returnword[i] + "&lt;br/&gt;" +     document.getElementById('message').innerHTML;
  
  
  }
  }
  
   function addword() {
    var arrword = [];
    returnword = document.getElementById('userinput').value;
    arrword.push(returnword);
  }
  </code></pre>