After spending hours working on my first JavaScript code, following the instructions in my textbook, I still can't get the table to display on my webpage. The id="eventList"
is already included in my HTML and I've shortened the arrays. Here's a snippet of my JS code:
var eventDates = ["July 29, 2018 11:00:00", "July 30, 2018 19:00:00"];
var eventDescriptions = ["Classics Brunch", "Lasers and Light"];
var eventPrices = ["$12", "$12/$18/$24"];
var thisDay = new Date("August 30, 2018");
var tableHTML = "<table id='eventTable'><caption>Upcoming Events</caption>
<tr><th>Date</th><th>Event</th><th>Price</th></tr>";
var endDate = new Date();
endDate = thisDay.getTime() + 14 * 24 * 61 * 61 * 1000;
for (var i = 0; i < eventDates.length; ++i) {
var eventDate = new Date();
eventDate = eventDates[i];
var eventDay = eventDate.toDateString();
var eventTime = eventDate.toLocaleTimeString();
if ((thisDay <= eventDate) && (eventDate <= endDate))
tableHTML = "<tr><td>eventDay @ eventTime</td><td>description</td>
<td>price</td></tr>" + eventDay + eventTime;
var description = eventDescriptions[i];
var price = eventPrices[i];
}
tableHTML = "</table>";
document.getElementById("eventList").innerHTML = tableHTML;
<div id="eventList">
</div>