-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjects_date_js.html
More file actions
26 lines (22 loc) · 877 Bytes
/
objects_date_js.html
File metadata and controls
26 lines (22 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Objects and Dates in JavaScript</title>
</head>
<body>
<script>
'use strict';
// Create an array of months for printing dates
let months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
// Create the date corresponding to your birthday using the JavaScript Date object.
let jsBirthday = new Date(1900, 1, 10); // February 10, 1900
// Log your birthday in the format: January 1, 2014 using the JavaScript Date object.
// Use getDate(), getMonth(), and getFullYear() methods.
let day = jsBirthday.getDate();
let month = months[jsBirthday.getMonth()];
let year = jsBirthday.getFullYear();
console.log('Here is my birthday using JavaScript: ' + month + ' ' + day + ', ' + year);
</script>
</body>
</html>