Calculate How Many Days There Are Between Two Dates in JavaScript
1 min read

There are many ways to check the days between two dates - this one uses a lot to iterate through each day and just add one for each day until we get the actual value.

const nightBetweenDates = (startDate, endDate) => {
	const start = new Date(startDate);
	const end = new Date(endDate);
	let dayCount = 0;

	while (end > start) {
		start.setDate(start.getDate() + 1);

	return dayCount;