How to return a lower-upper Direct Random number by JavaScript
This article mainly introduces JavaScript how to return a lower-upper direct random number, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Random: returns a random number directly from lower-upper. (lower, upper, no matter positive or negative or small, but must be non-NaN data)
Function random (lower, upper) {lower = + lower | | 0 upper = + upper | | 0 return Math.random () * (upper-lower) + lower } / / random (0,0.5) = > 0.3567039135734613//random (2,1) = = > 1.6718418553475423//random (- 2,-1) = >-what is 1.4474325452361945JavaScript? JavaScript is a literal scripting language whose interpreter is called JavaScript engine and is part of the browser. JavaScript is a scripting language widely used on the client side. It was first used on HTML pages to add dynamic functions to HTML pages.
Thank you for reading this article carefully. I hope the article "how to return a lower-upper direct random number" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!