My code is not working someone help me please and thank you?
1. Declare a variable named thisDay containing the date August 30, 2018. You will use this date to test your script. 2. 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 Date | Event | Price |
3. Lewis only wants the page to list events occurring within 14 days after the current date. Declare a variable named endDate that contains a Date object that is 14 days after the date stored in the thisDay variable. (Hint: Use the new Date() object constructor and insert a time value that is equal to thisDay.getTime() + 14*24*60*60*1000.) 4. Create a for loop that loops through the length of the eventDates array. Use i as the counter variable. 5. Within the for loop insert the following commands in a command block: a. Declare a variable named eventDate containing a Date object with the date stored in the ith entry in the eventDates array. b. Declare a variable named eventDay that stores the text of the eventDate date using the toDateString() method. c. Declare a variable named eventTime that stores the text of the eventDate time using the toLocaleTimeString() method. d. Insert an if statement that has a conditional expression that tests whether thisDay is ? eventDate and eventDate ? 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. 6. After the for loop, add the text of the HTML code
to the value of the tableHTML variable. 7. Insert the value of the tableHTML variable into the inner HTML of the page element with the ID eventList. 8.. Document your code in the script file using appropriate comments.
My code:
"use strict";
/*
New Perspectives on HTML5 and CSS3, 7th Edition
Tutorial 10
Review Assignment
Author:
Date:
*/
/* variable use to test script */
var thisDay= new Date("August 30, 2018");
/* Contains HTML code of the event table */
var tableHTML=""
var tableData='
Upcoming EventsDate | Event | Price |
' tableHTML= tableHTML.Concat(tableData);
/*date object that is 14 days after the date stored in thisDay variable */
var endDate = new Date(thisDay.getTime()+14*24*60*60*1000);
var eventDates = ["september 10, 2018","september 15, 2018","september 30, 2018","september 20, 2018"];
var eventDescriptions = ["aaa","bbb","cccc","dddd"];
var eventPrices = ["10", "20","30","40"];
/* loop for the lenght of eventDates */
for(var i=0; i {
var eventDate= new Date(eventDates[i]);
var eventDay= eventDate.toDateString();
var eventTime= eventDate.toLocaleTimeString();
var description = eventDescriptions[i];
var price = eventPrices[i];
if(thisDay < eventDate && eventDate < endDate)
{
tableHTML= tableHTML.concat('
').concat(eventDay).concat("@").concat(eventTime).concat(' | ').concat(description).concat(' | ').concat(price).concat(' |
');
}
}
tableHTML=tableHTML.concat('
');
document.getElementById("eventList").innerHTML = tableHTML;