DEV Community

Discussion on: Random numbers using Node.js package

Collapse
 
khrisl33t profile image
kHRISl33t • Edited

Why would you need a package for this scenario if you could do:

const generateRandomInt = (min, max) => Math.floor(Math.random() * (max - min)) + min;
Enter fullscreen mode Exit fullscreen mode

A package less, and only 1 line of code :)

In my opinion, it's not good to use packages which are doing very obvious things, you can easily implement these and you have more control if you want to change it later. (but that's my opinion)

Or if you want to use it to create fake data for a DB seed, you could use faker which has the same functionality.