Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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');
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #JavaScript #function #generates #combinations
ADD COMMENT
Topic
Name
6+1 =