-2

Is there a way that I can possibly do [200:204] in JavaScript to generate this array [200, 201, 202, 203]?

Gaurav Paliwal
  • 1,456
  • 17
  • 26
John Mutuma
  • 2,430
  • 2
  • 17
  • 28

1 Answers1

2

You can do

const range = (a, b) => Array(b-a).fill(a).map((v, i) => v + i);

And then use

const arr = range(200, 204);
Ingo Bürk
  • 17,703
  • 6
  • 60
  • 91