const enumerateDaysBetweenDates = (startDate, endDate) => { let daysList = []; const start = moment(startDate); const end = moment(endDate); const day = end.diff(start, "year"); daysList.push(start.format("YYYY")); for (let i = 1; i <= day; i++) { daysList.push(start.add(1, "year").format("YYYY")); } return daysList; }; enumerateDaysBetweenDates('2001','2005'); //['2001', '2002', '2003', '2004', '2005']