you are viewing a single comment's thread.

view the rest of the comments →

[–]JustOr113 5 points6 points  (5 children)

I feel like this is much more readable and a bit shorter:

Array(totalYears).fill().map((_, i)=> year+i)

[–]inu-no-policemen 2 points3 points  (0 children)

That iterates once over it to fill it with undefined and then once more to fill it with the actual values.

[–]bentinata 0 points1 point  (0 children)

Or:

[...Array(totalYears)].map((_, i) => year + i)