Initial commit
This commit is contained in:
commit
3e92397fe1
23 changed files with 459 additions and 0 deletions
25
content/home/index.js
Normal file
25
content/home/index.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Source - https://stackoverflow.com/questions/4076321/javascript-age-calculation
|
||||
// Posted by Matt
|
||||
// Retrieved 2025-11-22, License - CC BY-SA 2.5
|
||||
function calculateAge(birthDate, otherDate) {
|
||||
var years = (otherDate.getFullYear() - birthDate.getFullYear());
|
||||
|
||||
if (otherDate.getMonth() < birthDate.getMonth() ||
|
||||
otherDate.getMonth() == birthDate.getMonth() && otherDate.getDate() < birthDate.getDate()) {
|
||||
years--;
|
||||
}
|
||||
|
||||
return years;
|
||||
}
|
||||
|
||||
function lyesAge() {
|
||||
let birth = new Date("2002-04-18")
|
||||
let today = new Date()
|
||||
return calculateAge(birth, today)
|
||||
}
|
||||
|
||||
function changeAge() {
|
||||
document.getElementById("age").setHTML(lyesAge())
|
||||
}
|
||||
|
||||
changeAge()
|
||||
Loading…
Add table
Add a link
Reference in a new issue