Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I\'m having a little bit of trouble with my JavaScript. Directions: JavaS

ID: 3913542 • Letter: H

Question

Hello,

I'm having a little bit of trouble with my JavaScript.

Directions:

JavaScript File

Variable Declaration

Declare a variable named thisTime containing a Dateobject for February 3, 2018 at 3:15:28 AM.

Use the toLocaleString()method to save the text of the thisTime variable in the timeStr variable.

Change the inner HTML code of the page element with the ID “timestamp” to the value of the timeStr variable.

Here's what I have so far and I'm not sure why it's not working.

/*

New Perspectives on HTML5 and CSS3, 7th Edition
Tutorial 9
Case Problem 1

Planisphere Script
Author: (Name)
Date: (Date)

*/

var thisTime = new Date();
var timeStr = thisTime.toLocaleString();
document.getElementById("timestamp").innerHTML = timeStr;

Wondering if you can help.

Thanks!

Explanation / Answer

If you have any doubts, please give me comment...

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8" />

</head>

<body>

<div id="timestamp">

</div>

<script type="text/javascript">

/*

New Perspectives on HTML5 and CSS3, 7th Edition

Tutorial 9

Case Problem 1

Planisphere Script

Author: (Name)

Date: (Date)

*/

var thisTime = new Date(2018, 2, 3, 15, 15, 28);

var timeStr = thisTime.toLocaleString('en-US', {

year: 'numeric',

month: 'long',

day: 'numeric',

hour: 'numeric',

minute: 'numeric',

second: 'numeric'

});

document.getElementById("timestamp").innerHTML = timeStr;

</script>

</body>

</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote