check date in between two dates nodejs

const startDate = new Date('2022-01-01'); const endDate = new Date('2022-12-31'); const currentDate = new Date('2022-07-15');

if (currentDate > startDate && currentDate < endDate) { console.log('The current date is between the start and end dates.'); } else { console.log('The current date is not between the start and end dates.'); }