Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I'm having a little trouble with my JavaScript. I've completed steps 1. and 2., but having trouble with 3, 4, and 5. Wondering if

Hello,

I'm having a little trouble with my JavaScript. I've completed steps 1. and 2., but having trouble with 3, 4, and 5. Wondering if you can help.

.

.

Directions:

Variables

1. Below the comment section, 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. Page creator 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 x 24 x 60 x 60 x 1000.)

For Loop

4. Create a for loop that loops through the length of theeventDates array. Use i as the counter variable.

5. Within the for loop insert the following commands in a command block:

a. Declare a variable namedeventDate containing aDate object with the date stored in the i 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 namedeventTime that stores the text of the eventDate time using thetoLocaleTimeString()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.

e. Where eventDay is the value of the eventDay variable,eventTime is the value of the eventTime variable, description is the i entry in the eventDescriptionsarray, and price is the ientry in the eventPricesarray.

.

.

I've done 1. and 2. so far, but having trouble with the rest.

Here's what I have so far:

var thisDay = ("August 30, 2018");

var tableHTML = ["

Upcoming Events
DateEventPrice
eventDay @ eventTime description price
"];

var endDate = new Date(thisDay.getTime() + 14 * 24 * 60 * 60 * 1000);

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions


Upcoming Events
DateEventPrice