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
{ | |
"name": "javascript-development-environment", | |
"version": "1.0.0", | |
"description": "JavaScript development environment Pluralsight course by Cory House", | |
"scripts": { | |
}, | |
"author": "Cory House", | |
"license": "MIT", | |
"dependencies": { | |
"whatwg-fetch": "1.0.0" |
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
function calcAge(year, month, day) { | |
const now = new Date(); | |
let age = now.getFullYear() - year; | |
const mdif = now.getMonth() - month + 1; // jan is 0 in getMonth | |
if (mdif < 0) { | |
// not birthday yet | |
--age; | |
} | |
else if (mdif === 0) { | |
// maybe birthday? |