-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c59fbf6
commit 1937173
Showing
3 changed files
with
21 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,8 @@ body{ | |
font-size: 15px; | ||
border-radius: 8px; | ||
} | ||
.display{ | ||
padding: 5px 0; | ||
font: 20px; | ||
font-size: 20px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
const date = document.getElementById('date'); | ||
const date = document.getElementById('date'); | ||
let btn = document.getElementById('btn') | ||
let dob = new Date(); | ||
let display = document.querySelector('.display'); | ||
btn.addEventListener('click', (e)=>{ | ||
e.preventDefault(); | ||
const enteredDate = date.value; | ||
let currentYear = dob.getFullYear(); | ||
let dateOfBirth = new Date(enteredDate); | ||
let getYear = dateOfBirth.getFullYear(); | ||
let age = currentYear - getYear; | ||
display.textContent = `Your age is ${age} years old` | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters