Record of common flash as methods

Source: Internet
Author: User

Copy codeThe Code is as follows:/** @ author: yapollo.li@gmail.com
* @ Power: output between min and max num random number
*/
Public function rand (max, min, num ){
Var a_array = new Array ();
Var B _array = new Array ();
Var;
For (var n = min; n <max; n ++ ){
A_array [n] = n + 1;
}
// Because need num, so loop num times
For (var k = 0; k <num; k ++ ){
// Randomly extract the_array position;
A = Math. floor (Math. random () * a_array.length );
// Feed the element value at this position to B _array;
B _array [k] = a_array [a];
// Delete the element at this position from the_array array, so that you do not need to pump it again next time.
A_array.splice (a, 1 );
}
// Display a new array of dynamic text
Return B _array;
}

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.