Get the App
SLTechnology News&Howtos  ›  Development  › 

How to return a lower-upper Direct Random number by JavaScript

Shulou Source: shulou.com Published: 2022-06-01 02:38:10 10月02日 Update

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!

Tags: Articles random numbers web pages scripts language value interest function dynamic at the same time size customer engine data right and wrong more friends plus or minus browser Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Technology Apple macOS Xiaomi