function getDaysBetween2Dates(startDate, endDate) {
const milliseconInADay = 24 * 60 * 60 * 1000;
return Math.round(Math.abs(endDate - startDate) / milliseconInADay);
}
console.log(getDaysBetween2Dates(new Date('2022-04-03'), new Date('2022-04-08')));
/*
run:
5
*/