I'm completely lost as to why the following code gives me a year of 2021 while executing this on the day of 01/03/2019... What... What am I missing... I so need a coding buddy sitting next to me I think.. >.<
function daysTillChristmas()
{
var today = new Date();
var christmasDay1 = new Date(today.getFullYear() +1, 12, 25);
var test = today.getFullYear() + 1;
var christmasDay2 = new Date(2020, 12, 25);
console.log(today);
console.log("Today: " + today);
console.log("Today Full Year: " + today.getFullYear());
console.log("ChristmasDay1: " + christmasDay1);
console.log(christmasDay2);
console.log("ChristmasDay2: " + christmasDay2);
console.log("Test: " + test);
}
My output is...
"2019-01-03T22:54:33.294Z"
Today: Thu Jan 03 2019 14:54:33 GMT-0800 (Pacific Standard Time)
Today Full Year: 2019
ChristmasDay1: Mon Jan 25 2021 00:00:00 GMT-0800 (Pacific Standard Time)
"2021-01-25T08:00:00.000Z"
ChristmasDay2: Mon Jan 25 2021 00:00:00 GMT-0800 (Pacific Standard Time)
Test: 2020
BTW... I'm learning Javascript at the moment and I'm using the following URL to test out code and get some exercises to use.
Browser: Chrome 70.0.3538.77 32-bit
https://www.w3resource.com/javascript-exercises/javascript-basic-exercises.php#EDITOR