Js Bubble Method and array conversion into string example code _ javascript skills

Source: Internet
Author: User
There are many ways to convert an array into a string, so I am sure you will not be familiar with it. The following describes how to use the js bubble method. If you are interested, refer to the js Code below:

The Code is as follows:


Window. onload = function (){
Var mian = document. getElementById ("mian ");
Var mian1 = document. getElementById ("mian1 ");
Var str = mian. innerHTML;
Var arry = [];
Var len = str. length;
For (var I = 0; I <len; I ++ ){
Arry [I] = str [I];
};
Function compute x1 (arry ){
Var temp;
While (len> 0 ){
For (var j = 0; j <len-1; j ++ ){
If (arry [j]> arry [j + 1]) {
Temp = arry [j];
Arry [j] = arry [j + 1];
Arry [j + 1] = temp;
};
};
Len --;
};
Return arry;
};
Mian1.innerHTML = bytes x1 (arry). join (""); // converts an array to a string.
};


Html code:

The Code is as follows:


Vdwsxdfrthspas


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.