The following code block will work well on Javascript and also on Typescript if you remove the function keyword. To understand the logic behind this implementation have a look at this link How to determine whether a year is a leap year.
function isLeapYear(year) { let isLeapObj = {}; if ((year % 4 === 0 && year % 100 != 0) || year % 400 === 0) { isLeapObj['isLeap'] = true; isLeapObj['days'] = 366; } else { isLeapObj['isLeap'] = false; isLeapObj['days'] = 365; } return isLeapObj; }x = isLeapYear(2020);console.log(x);
For Javscript use the following code