js implements numerical probability calculation

php中世界最好的语言
Release: 2018-04-17 13:31:21
Original
2907 people have browsed it

This time I will bring youjsimplementation 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"; }
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!