We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7fbabad commit 2d4c46bCopy full SHA for 2d4c46b
_includes/landing.html
@@ -50,3 +50,4 @@ <h3 class="font-weight-bold">Hi! Welcome to my website</h3>
50
}
51
</style>
52
53
+<script src="{{ '/assets/js/age-calculator.js' | relative_url }}"></script>
assets/js/age-calculator.js
@@ -0,0 +1,13 @@
1
+function ageCalculator() {
2
+ var today = new Date();
3
+ var birthDate = new Date("2000-10-06"); // ISO-8601 format
4
+ var age = today.getFullYear() - birthDate.getFullYear();
5
+ var m = today.getMonth() - birthDate.getMonth();
6
+ if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
7
+ age--;
8
+ }
9
+
10
+ document.querySelector("#age").innerHTML = age;
11
+}
12
13
+ageCalculator();
0 commit comments