Last active
October 6, 2015 15:02
-
-
Save gaand/7d8c5ac8b25a9f4dfd62 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var age = function age() { | |
var dob = new Date(this.dob); | |
var today = new Date(); | |
var thisYear = today.getFullYear(); | |
if (dob.getMonth() > today.getMonth() || | |
dob.getMonth() === today.getMonth() && | |
dob.getDate() >= today.getDate()) { | |
thisYear -= 1; | |
} | |
return thisYear - dob.getFullYear(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment