This time I will bring you jsimplementation of digital probability calculation, js implementation of digital probability calculationWhat are the precautions, the following is the actual combat Let’s take a look at the case.
Core code:
//7:3运算 if(Math.ceil(Math.random()*10)>3){ //占比=7 alert('7'); window.location.href="http://www.baidu.com" rel="external nofollow" ; }else{ //占比=3 alert(3); widnow.location.href="http://www.jb51.net"; }
Use the size of the random number to determine which URL is best to visit. You can modify it according to your own needs.
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
Handling the compatibility issues of the Date() function in the browser
angularJS Ionic on the mobile side Upload images (with code)
The above is the detailed content of js implements numerical probability calculation. For more information, please follow other related articles on the PHP Chinese website!