JavaScript generates welfare lottery Shuangse Qiu number _javascript tips

Source: Internet
Author: User

The Shuangse Qiu number of the welfare lottery is made up of 6 red ball numbers and a basketball number, of which 6 red ball numbers are randomly drawn from 01 to 33 6 digits, and 1 basketball numbers are randomly drawn from 01 to 16. 6 red ball numbers are usually arranged in a small to large order. The following is a way to generate a note shuangse Qiu number in JavaScript for your reference!

var redball = new Array ();
var redlen = redball.length;
while (redlen<6) {
var ball = Rannumber (1,33);
var flag = true; for
(Var j=0;j<redlen;j++) {
if (red   Ball[j]==ball) {
flag = false;
break;
}
if (flag) {
if (ball<10) {
Redball.push ("0″+ball);
}  else{
redball.push (ball);
}
redlen = redball.length;
}
Redball.sort ();
var BlueBall = Rannumber (1,16);
if (blueball<10) {
BlueBall = "0″+blueball;
}
Alert (Redball.join (', ') + "|" + BlueBall);  

Here is the Rannumber method, which returns a random integer between S and E.

function Rannumber (s,e) {
var staval = parsefloat (s);
var endval = parsefloat (e); return
Math.floor (Math . Random () * (Endval-staval) +staval);


The above mentioned is the entire content of this article, I hope you can enjoy.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.