-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,556
  • 16
  • 27
John Mutuma
  • 3,150
  • 2
  • 18
  • 31

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
  • 19,263
  • 6
  • 66
  • 100