Skip to content

Instantly share code, notes, and snippets.

@Shaxadhere
Created September 2, 2022 11:01
Show Gist options
  • Save Shaxadhere/d76035f8cebe4d829215dacfa09541a8 to your computer and use it in GitHub Desktop.
Save Shaxadhere/d76035f8cebe4d829215dacfa09541a8 to your computer and use it in GitHub Desktop.
function getDayNames(from, to) {
var d = new Date(from),
to = new Date(to),
a = [],
y = [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
];
while (d < to) {
console.log(d.getDay());
a.push(y[d.getDay()]);
d.setDate(d.getDate() + 1);
}
if (d.getDay() === to.getDay()) a.push(y[d.getDay()]);
console.log(a);
a = a.filter((item, i, ar) => ar.indexOf(item) === i);
return a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment