Question
Hello. I was hoping to find some help with JavaScript. Here are the directions: Javascript Functions Directly above the nextJuly4() function, insert a function named
Hello. I was hoping to find some help with JavaScript.
Here are the directions:
Javascript Functions
Directly above the nextJuly4() function, insert a function named showClock() that has no parameters. Within the showClock() function, complete Steps below.
1. Declare a variable named thisDay that stores a Date object containing the date May 19, 2018 at 9:31:27 a.m.
2. Declare a variable named localDate that contains the text of the date from the thisDay variable using local conventions. Declare another variable named localTime that contains the text of the time stored in the thisDay variable using local conventions.
3. Within the inner HTML of the page element with the ID currentTime, write the following code datetime where date and timeare the values of the localDate and localTime variables.
4. Hector has supplied you with a function named nextJuly4() that returns the date of the next 4th of July. Call the nextJuly4() function using thisDay as the parameter value and store the date returned by the function in the j4Date variable.
5. The countdown clock should count down to 9 p.m. on the 4th of July. Apply the setHours() method to the j4Date variable to change the hours value to 9 p.m. (Hint: Express the value for 9 p.m. in 24-hour time.)
6. Create variables named days, hrs, mins, and secs containing the days, hours, minutes, and seconds until 9 p.m. on the next 4th of July. (Hint: Use the code from the tny_script.js file in the tutorial case as a guide for calculating these variable values.)
7. Change the text content of the elements with the IDs dLeft, hLeft, mLeft, and sLeft to the values of the days, hrs, mins, and secs variables rounded down to the next lowest integer.
JavaScript Commands
Directly after the opening comment section in the file, insert a command to call the showClock() function.
After the command that calls the showClock() function, insert a command that runs the showClock() function every second.
Here's my code so far:
/* New Perspectives on HTML5 and CSS3, 7th Edition Tutorial 9 Review Assignment
Event Timer Author: XXX Date: XXX
*/ function showClock() { }
function nextJuly4(currentDate) { var cYear = currentDate.getFullYear(); var jDate = new Date("July 4, 2018"); jDate.setFullYear(cYear); if ((jDate - currentDate) < 0) jDate.setFullYear(cYear + 1); return jDate; }
var thisDay = new Date(); var j4Date = nextJuly4(thisDay); j4Date.setHours(21); document.write(j4Date);
Thank you!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started