title: JavaScript Arrays Issue With Printing Results
body: <p>Hello I'm trying to create an app that accepts input from a user then sends it to an array to be printed to the screen. I'm having trouble getting array to loop properly, and print to the screen. Here's what I have so far:</p>
  
  <pre><code>var groceries = getGroceries();
  printGroceries(groceries);
  
  function getGroceries() {
  
      var canExit = false;
      var myGroceries = new Array();
      while (myGroceries != 'q') {
  
          myGroceries = prompt("Enter an item to add to the grocery list (enter \‘q\’ to quit):", null);
  
          if ((myGroceries !== null) &amp;&amp; (myGroceries != "q")) {
              myGroceries.push(myGroceries);
              canExit = true;
          }
      }
      return myGroceries;
  
  }
  
  function printGroceries() {
  
      if (myGroceries.length &gt; 0) {
          document.write("Here’s your grocery list:&lt;br&gt;&lt;br&gt;" + myGroceries.join("&lt;br&gt;&lt;br&gt;"));
  
          } else {
              document.write("Sorry, your list is empty.");
  
          }
  }
  </code></pre>