const getDatesBetweenDates = (startDate, endDate) => {
let dates = [];
const endDateObject = new Date(endDate);
const iteratorDate = new Date(startDate);
// Analyser complains about the next line
while (iteratorDate < endDateObject) {
dates = [...dates, new Date(iteratorDate)];
iteratorDate.setDate(iteratorDate.getDate() + 1);
}
dates = [...dates, new Date(endDate)];
let sortedDates = dates.sort((a, b) => a - b);
console.log('Dates between:', sortedDates);
return sortedDates;
};
The analyser is complaining that iteratorDate
and endDateObject
are not modified in the while
loop, but iteratorDate
is modified.