Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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:

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. 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
Upcoming Events
DateEventPrice
eventDay @ eventTime description price
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='

'

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('

');

}

}

tableHTML=tableHTML.concat('

Upcoming Events
DateEventPrice
').concat(eventDay).concat("@").concat(eventTime).concat('').concat(description).concat('').concat(price).concat('
');

document.getElementById("eventList").innerHTML = tableHTML;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions