Skip to main content
4 of 4
added 192 characters in body
mplungjan
  • 180k
  • 29
  • 183
  • 246

In ES6 you can do:

Array(N).fill().map((e,i)=>i+1);

http://jsbin.com/molabiluwa/edit?js,console

Edit: Changed Array(45) to Array(N) since you've updated the question.

console.log( Array(45).fill(0).map((e,i)=>i+1) );

Nate
  • 6.5k
  • 3
  • 27
  • 31