I needed to create multiple dynamic year ranges as arrays. I found this solution could be interesting to you:
const years = 60
let current = new Date().getFullYear()
Array(...Array(years)).map(() => current--)
// [2019,2018,2017, ... , 1961, 1960]
Of course you can use this to create any kind of numeric ranges, years is just an example. I hope it helps! :)
Top comments (0)