Skip to content

Instantly share code, notes, and snippets.

@katepapineni
Created August 3, 2020 16:03
Show Gist options
  • Save katepapineni/5f2a15ae9d1c0ac100a78d204b214313 to your computer and use it in GitHub Desktop.
Save katepapineni/5f2a15ae9d1c0ac100a78d204b214313 to your computer and use it in GitHub Desktop.
const getRange = (start, end) => {
const range = [];
const date = new Date(start);
const toDate = new Date(end);
while (date <= toDate) {
range.push(new Date(date));
date.setDate(date.getDate() + 1);
}
return range;
};
// What's the output?
console.log(getRange('2020-08-04', '2020-08-07'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment