-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
54 lines (34 loc) · 946 Bytes
/
scripts.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const monthEl= document.querySelector(".date h1");
const fullDateEl= document.querySelector(".date p");
const daysEl = document.querySelector(".days")
const monthInx = new Date().getMonth()
const lastDay = new Date(new Date().getFullYear(), monthInx + 1, 0).getDate();
const firstrDay = new Date(new Date().getFullYear(), monthInx, 1).getDay();
const months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];
monthEl.innerText = months[monthInx];
fullDateEl.innerText = new Date().toDateString();
let days = "";
for(let i = firstrDay; i>0; i--){
days += `<div class= "empty"></div>`
}
for (let i =1; i<= lastDay; i++ ) {
if (i===new Date().getDate()) {
days += `<div class="today">${i}</div>`;
}else {
days += `<div>${i}</div>`;
}
}
daysEl.innerHTML = days;