Skip to content

Instantly share code, notes, and snippets.

@alDuncanson
Last active March 29, 2022 20:38
Show Gist options
  • Save alDuncanson/a261e9bf8512545eb9e35ea5a5266783 to your computer and use it in GitHub Desktop.
Save alDuncanson/a261e9bf8512545eb9e35ea5a5266783 to your computer and use it in GitHub Desktop.
Get array of years up until current year (ex. yearsAgo(5) => [2018, 2019, 2020, 2021, 2022])
const yearsAgo = year => Array.from([...Array(year)].fill(new Date().getFullYear()), (value, index) => value - index).reverse()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment