Q:

Javascript/for loop/HTML table positioning

Description of program:
-My program uses a javascript for loop to place the data from an external javascript array named "arrays.js" into an HTML table. This program is suposed to place the correct data under  the "Date Name Address Amount" table headings.
Problem:
-The data in the array is overstepping its boundarys or I should say lack of boundaries set within the table headers "Date Name Address Amount" Its not creating a new record after the "Amount" header, its simply adding the new record to the same line.I would like it to wrap back around to the next record row starting under "Date" table header. so that the dates value in the arrya will be under the "date" header, name value under the "Name" header...etc example bellow....
Example: I have 4 headers (Date, Name, Address, Amount) I would like the start of the next date under the next array to be placed under the "Date" table header.It placing the next date value of the array on the same row its not wraping around to a new record row. Code is bellow.
Date         Name           Address     Amount  
index.html
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Winch - Lab 10</title>
        <script src="arrays.js" type="text/javascript"></script>
        <script type="text/javascript">
            function totalContributions()
            {
                var totalAmount = 0;
                for (var i = 0; i < amount.length; i++)
                    totalAmount = totalAmount + amount[i];
                return totalAmount;
            }

        </script>
    </head>
    <body>
     <table id="donations">
         <tr>
             <th>Date</th>
             <th>Name</th>
             <th>Address</th>
             <th>Amount</th>
         </tr>
         <script>
             for (var x=0; x < amount.length; x++){
                 if (x%2==0){
                    document.write("<tr>");
                 } else {
                     document.write("<tr class='stripe'>");
                 }
                  document.write("<td>"+date[x]+"</td>");
                  document.write("<td>"+firstName[x]+" "+lastName[x]+"</td>");
                  document.write("<td>"+street[x]+"<br>"+city[x]+","+state[x]+" "+zip[x]);
                  document.write("<td class='amt'>$"+amount[x]+"</td>");
                  document.write("</tr)");
             }

         </script>
     </table>
    </body>
    </html>

**arrays.js**

street = new Array();
city = new Array();
state= new Array();
zip = new Array();
amount = new Array();
date = new Array();

firstName[0]="Ron";
lastName[0]="Burgundy";
street[0]="88 Regal Lane";
city[0]="Williamsburg";
state[0]="KY";
zip[0]="40769";
amount[0]=625;
date[0]="2015-07-18";

firstName[1]="Ricky";
lastName[1]="Bobby";
street[1]="407 Easy Street";
city[1]="London";
state[1]="KY";
zip[1]="40744";
amount[1]=75;
date[1]="2015-07-18";

firstName[2]="Veronica";
lastName[2]="Corningstone";
street[2]="743 Stawlings Drive";
city[2]="Danville";
state[2]="KY";
zip[2]="40423";
amount[2]=50;
date[2]="2015-07-16";

firstName[3]="Brick";
lastName[3]="Tamland";
street[3]="102 Maple Lane";
city[3]="Danville";
state[3]="KY";
zip[3]="40423";
amount[3]=150;
date[3]="2015-07-15";

A:

1) You forgot to define firstName and lastName variables in arrays.js file.
2) Inside for-loop the tr tag is not closed, changed document.write("</tr)"); to document.write("</tr>");.
Working Code:
Html Code:
` 
    
    
        
        Winch - Lab 10
        
        
            function totalContributions()
            {
                var totalAmount = 0;
                for (var i = 0; i < amount.length; i++)
                    totalAmount = totalAmount + amount[i];
                return totalAmount;
            }
    </script>
</head>
<body>
 <table id="donations" style="width:100%;" border="1">
     <tr>
         <th>Date</th>
         <th>Name</th>
         <th>Address</th>
         <th>Amount</th>
     </tr>
     <script>
         for (var x=0; x < amount.length; x++){
             if (x%2==0){
                document.write("<tr>");
             } else {
                 document.write("<tr class='stripe'>");
             }
              document.write("<td>"+date[x]+"</td>");
              document.write("<td>"+firstName[x]+" "+lastName[x]+"</td>");
              document.write("<td>"+street[x]+"<br>"+city[x]+","+state[x]+" "+zip[x]);
              document.write("<td class='amt'>$"+amount[x]+"</td>");
              document.write("</tr>");
         }

     </script>
 </table>
</body>
</html>

arrays.js
street = new Array();
city = new Array();
state= new Array();
zip = new Array();
amount = new Array();
date = new Array();
firstName = new Array();
lastName = new Array();

firstName[0]="Ron";
lastName[0]="Burgundy";
street[0]="88 Regal Lane";
city[0]="Williamsburg";
state[0]="KY";
zip[0]="40769";
amount[0]=625;
date[0]="2015-07-18";

firstName[1]="Ricky";
lastName[1]="Bobby";
street[1]="407 Easy Street";
city[1]="London";
state[1]="KY";
zip[1]="40744";
amount[1]=75;
date[1]="2015-07-18";

firstName[2]="Veronica";
lastName[2]="Corningstone";
street[2]="743 Stawlings Drive";
city[2]="Danville";
state[2]="KY";
zip[2]="40423";
amount[2]=50;
date[2]="2015-07-16";

firstName[3]="Brick";
lastName[3]="Tamland";
street[3]="102 Maple Lane";
city[3]="Danville";
state[3]="KY";
zip[3]="40423";
amount[3]=150;
date[3]="2015-07-15";

