Horje
JavaScript function that generates all combinations of a string. Code Example
JavaScript function that generates all combinations of a string.
function combu(s){
var buff = [];
var res = [];
for (i=0;i<s.length;i++){
    buff = [s[i]];
    var index=0;
    while(res[index]){
        buff.push(''+res[index]+s[i]);
        index++;
    }
    res = res.concat(buff);
}
return res;
}

combu('abc');
JavaScript function that generates all combinations of a string.
 function combString(str){
     var lenStr = str.length;
     var result = [];
     var indexCurrent = 0;

     while(indexCurrent < lenStr){
         var char = str.charAt(indexCurrent);
         var x;
         var arrTemp = [char];

         for(x in result) {
             arrTemp.push(""+result[x]+char);
         }
         result = result.concat(arrTemp);

         indexCurrent++;
     }

     return result;
}

console.log(combString("abc"));




Javascript

Related
check url if it has trailing slash Code Example check url if it has trailing slash Code Example
js class Code Example js class Code Example
live server in javascript Code Example live server in javascript Code Example
double logical not javascript Code Example double logical not javascript Code Example
express proxy Code Example express proxy Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
12