Printing each value of an array on a separate line Javascript
<p>I have a program that involves Javascript to allow for interaction with a webpage. It's a baseball site so what I am doing is prompting the user to enter a month. The user can enter a number, like 6 for June, or the name of the month itself and the program will display all the games they are playing that month.</p>

<p>The way I did this was to create an array and store it with the game information. So the month of July would look something like this:</p>

<pre><code>if(month == 7)    // July
{
    var gamesPlayed = ["7/1/16: Team1 @ Team2", "7/3/16: Team2 @ Team 4",
                       "7/4/16: Team3 @ Team2" , ... ,etc, ...];
}
</code></pre>

<p>In my main function (the one that executes when I push the Submit button), I want to print the array.</p>

<pre><code>var schedule = getSchedule(July);

for(var i = 0; i &lt; schedule.length; i++)
{
    document.getElementById("result").innerHTML = schedule[i] + "&lt;br /&gt;";
}
</code></pre>

<p>For some reason this does not work. All it does it print the very last value in the array and not the whole thing. How come it is not printing the whole array? I tried to do <code>document.write(schedule[i] + "&lt;br /&gt;");</code> and that didn't do what I wanted. It printed it, but it printed it on a page by itself to where I couldn't time in a new month or go back to a homepage, etc. Is there a way to get this to print all the elements and not just the last one?</p>