Something is missing from my code, looking for helping spotting the issue. Open the lht_table.js file and below the comment section, declare a variable named thisDay containing the date October 1, 2021. You will use this date to test your script. Create a variable named tableHTML that will contain the HTML code of the events table. Add the text of the following HTML code to the initial value of the variable: Upcoming Events DateEventPrice Declare a variable named endDate that contains a Date object that is 14 days after the date stored in the thisDay variable. Use the new Date() object constructor and insert a time value that is equal to thisDay.getTime() + 14*24*60*60*1000. Create a for loop that loops through the length of the eventDates array. Use i as the counter variable. Within the for loop insert the following commands in a command block: Declare a variable named eventDate containing a Date object with the date stored in the ith entry in the eventDates array. Declare a variable named eventDay that stores the text of the eventDate date using the toDateString() method. Declare a variable named eventTime that stores the text of the eventDate time using the toLocaleTimeString() method. Insert an if statement that has a conditional expression that tests whether thisDay ≤ eventDateandeventDate ≤ endDate`. If so, the event falls within the two-week window that Lewis has requested and the script should add the following HTML code text to the value of the tableHTML variable. eventDay @ eventTime description price where eventDay is the value of the eventDay variable, eventTime is the value of the eventTime variable, description is the ith entry in the eventDescriptions array, and price is the ith entry in the eventPrices array. After the for loop, add the text of the HTML code to the value of the tableHTML variable. Insert the value of the tableHTML variable into the inner HTML of the page element with the ID eventList. Document your code in the script file using appropriate comments. Open the website in the browser preview. Verify that the page shows theater events over a two-week period starting with Friday, October 1, 2021 and concluding with Thursday, October 14, 2021. I have done the work, see below, I however cannot seem to understand why the table is not showing up. Any help would be apprciated. var thisDay = new Date("October 1, 2021"); var tableHTML = "" + "Upcoming Events" + "DateEventPrice"; var endDate = thisDay.getTime() + 14 * 24 * 60 * 60 * 1000; for(var i = 0; i < eventDate; i++) { var eventDate = new Date(eventDates[i]); var eventDay = eventDate.toDateString(); var eventTime = eventDate.toLocaleTimeString(); if(thisDay <= eventDate && eventDate <= endDate) { tableHTML = tableHTML + "" + eventDay + "@" + eventTime+ "" + eventDescriptions[i] + "" + eventPrices + ""; } } tableHTML = tableHTML + ""; document.getElementById("eventList").innerHTML = tableHTML;
Something is missing from my code, looking for helping spotting the issue.
Open the lht_table.js file and below the comment section, declare a variable named thisDay containing the date October 1, 2021. You will use this date to test your script. Create a variable named tableHTML that will contain the HTML code of the events table. Add the text of the following HTML code to the initial value of the variable:
<table id='eventTable'>
<caption>Upcoming Events</caption>
<tr><th>Date</th><th>Event</th><th>Price</th></tr>
Declare a variable named endDate that contains a Date object that is 14 days after the date stored in the thisDay variable.
Use the new Date() object constructor and insert a time value that is equal to thisDay.getTime() + 14*24*60*60*1000.
Create a for loop that loops through the length of the eventDates array. Use i as the counter variable.
Within the for loop insert the following commands in a command block:
- Declare a variable named eventDate containing a Date object with the date stored in the ith entry in the eventDates array.
- Declare a variable named eventDay that stores the text of the eventDate date using the toDateString() method.
- Declare a variable named eventTime that stores the text of the eventDate time using the toLocaleTimeString() method.
- Insert an if statement that has a conditional expression that tests whether thisDay ≤ eventDateandeventDate ≤ endDate`. If so, the event falls within the two-week window that Lewis has requested and the script should add the following HTML code text to the value of the tableHTML variable. <tr> <td>eventDay @ eventTime</td> <td>description</td> <td>price</td> </tr> where eventDay is the value of the eventDay variable, eventTime is the value of the eventTime variable, description is the ith entry in the eventDescriptions array, and price is the ith entry in the eventPrices array.
After the for loop, add the text of the HTML code </table> to the value of the tableHTML variable. Insert the value of the tableHTML variable into the inner HTML of the page element with the ID eventList.
Document your code in the script file using appropriate comments. Open the website in the browser preview. Verify that the page shows theater events over a two-week period starting with Friday, October 1, 2021 and concluding with Thursday, October 14, 2021.
I have done the work, see below, I however cannot seem to understand why the table is not showing up. Any help would be apprciated.
var thisDay = new Date("October 1, 2021");
var tableHTML = "<table id='eventTable'>" + "<caption>Upcoming Events</caption>" + "<tr><th>Date</th><th>Event</th><th>Price</th></tr>";
var endDate = thisDay.getTime() + 14 * 24 * 60 * 60 * 1000;
for(var i = 0; i < eventDate; i++) {
var eventDate = new Date(eventDates[i]);
var eventDay = eventDate.toDateString();
var eventTime = eventDate.toLocaleTimeString();
if(thisDay <= eventDate && eventDate <= endDate) {
tableHTML = tableHTML + "<tr><td>" + eventDay + "@" + eventTime+ "</td><td>" + eventDescriptions[i] + "</td><td>" + eventPrices + "</td></tr>";
}
}
tableHTML = tableHTML + "</table>";
document.getElementById("eventList").innerHTML = tableHTML;
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images