1function combu(s){
2var buff = [];
3var res = [];
4for (i=0;i<s.length;i++){
5 buff = [s[i]];
6 var index=0;
7 while(res[index]){
8 buff.push(''+res[index]+s[i]);
9 index++;
10 }
11 res = res.concat(buff);
12}
13return res;
14}
15
16combu('abc');
1 function combString(str){
2 var lenStr = str.length;
3 var result = [];
4 var indexCurrent = 0;
5
6 while(indexCurrent < lenStr){
7 var char = str.charAt(indexCurrent);
8 var x;
9 var arrTemp = [char];
10
11 for(x in result) {
12 arrTemp.push(""+result[x]+char);
13 }
14 result = result.concat(arrTemp);
15
16 indexCurrent++;
17 }
18
19 return result;
20}
21
22console.log(combString("abc"));