Hi, can anyone explain if i am suppose to somehow connect the JavaScript console to my HTML file to get the date to appear in my HTML page. I don’t quite understand. It’s straight forward enough but obviously something is missing?
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Today's Date</title>
</head>
<body>
</body>
</html>
If you save the above HTML file, and load it into the browser of your choice, you should see a blank page with the title of the page as Today's Date
.
You can then open up the Console and begin working with JavaScript to modify the page. We’ll begin by using JavaScript to insert a heading into the HTML.
let d = new Date();
document.body.innerHTML = "<h1>Today's date is " + d + "</h1>"
You’ll receive the following output on the Console:
Output"<h1>Today's date is Sat Jun 24 2017 12:16:14 GMT-0400 (EDT)</h1>"
And at this point, your page should look similar to this: