DEV Community

Discussion on: Rando.js: replacing Math.random()

Collapse
 
mich_cook profile image
mich

This looks quite useful. Given that Math.random() returns a float, what drove your decision to make int the default return type in the numerical instances such as rando(5) and rando(5,10) instead of float? Was it an assumption that most people specifying numbers were looking for ints or something else?

Collapse
 
nastyox1 profile image
nastyox

Thanks! That's a great thought. And yes, that's exactly right. I've seen ints as a much more common use case than floats (excluding [0-1)), so I decided to make that the easier of the two. If you have other thoughts on the project, I'm always interested to hear feedback. You can leave a comment here, DM me on here, or create a pull request on my GitHub.