The idea was to calculate the number of days in a year from a specific date taking into account leap years. The expected result was either 365 or 366. In practice I got one day more than expected.
This what I tried I expected to get 366 here, given that 2024 is a leap year.
let startDate = new Date();
console.log(startDate)
// Reset to start from 00:00:00
startDate = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());
console.log(startDate)
let endDate = new Date(startDate.getFullYear()+1, startDate.getMonth(), startDate.getDate());
console.log(endDate)
console.log((endDate - startDate)/(1000*60*60*24)) // 366