generated from kerolloz/exams-table
-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
37 lines (28 loc) · 855 Bytes
/
script.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
const $ = document.querySelector.bind(document);
(() => {
/*
* month :
* 0 jan, 1 feb, 2 march, 3 apr
*/
const END_DATE = new Date(2023, 3); // april 2023
if (isItOver(END_DATE)) return showEndParagraph();
// Get today's date and time
const now = new Date();
// Find the distance between now and the count down date
const distance = END_DATE - now;
// Time calculations for days
const days = Math.floor(distance / (1000 * 60 * 60 * 24));
$("#countdown").innerText = `${days} days to freedom...`;
// If the count down is over
if (distance < 0) {
clearInterval(countDownInterval);
showEndParagraph();
}
})();
function isItOver(endDate) {
return endDate - Date.now() < 0;
}
function showEndParagraph() {
$("#counter").innerHTML =
"<p> YOU <em> SURVIVED </em> IT! <br>Enjoy your life! </p>";
}