Skip to content

Instantly share code, notes, and snippets.

@alDuncanson
Last active March 29, 2022 20:38
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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