Skip to content

Instantly share code, notes, and snippets.

@StrykerKent
Created October 18, 2018 17:52
Show Gist options
  • Save StrykerKent/188f6d8d0b421f8cdfb5b2299cc40a10 to your computer and use it in GitHub Desktop.
Save StrykerKent/188f6d8d0b421f8cdfb5b2299cc40a10 to your computer and use it in GitHub Desktop.
I was asked to iterate through each day from today to the first of this year and only print out date information for each Wednesday. I used pure JavaScript to do this.
var now = new Date();
for (var d = now; d >= new Date(new Date().getFullYear(), 0, 1); d.setDate(d.getDate() - 1)) {
if (d.getDay() == 3) {
console.log(new Date(d));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment