DEV Community

Discussion on: Write a simple but impactful script

Collapse
 
pichardoj profile image
J. Pichardo • Edited

Just wanted to share my script :p


Array.from(Array(1001).keys())
  .map(number => number.toString().padStart(4, '0'))
  .sort(number => number - Math.random() * number * 2);

Collapse
 
kyserrecchia profile image
kyserrecchia • Edited

Only gets all the numbers from 0000 to 0999.

edit: Simple fix though I think - should say Array(10000) not Array(1000)

Collapse
 
pichardoj profile image
J. Pichardo

Hey good catch, thanks.