Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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"));
Comment

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');
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript get array min and max 
Javascript :: count number of word in javascript 
Javascript :: center element in react native 
Javascript :: how to generate random number in javascript 
Javascript :: vue cli - Uncaught SyntaxError: Unexpected token < 
Javascript :: select default value react 
Javascript :: opencv rtsp stream python 
Javascript :: how to append value to input field using jquery 
Javascript :: ternary operator angular template 
Javascript :: styled components import google font 
Javascript :: Removing Service Workers Programmatically 
Javascript :: $ is not a function 
Javascript :: js concat variable and string 
Javascript :: nodejs await inside map 
Javascript :: jquery boilerplate 
Javascript :: get name jquery 
Javascript :: How to hthe amount of users online in discordjs 
Javascript :: array to string javascript 
Javascript :: javaSript string first words to upper case 
Javascript :: classname did not match server next js styled components 
Javascript :: What is the Difference between Undefined, undeclared, Null 
Javascript :: how to make @click in router-link vuejs 
Javascript :: Min Stack Algorithm JS 
Javascript :: @angular/common@11.2.1 node_modules/@angular/common @angular/common@"11.2.1" from the root project 
Javascript :: mongoose schema cast decimals 
Javascript :: change node version 
Javascript :: show hide element jquery 
Javascript :: useeffect clearinterval loading 
Javascript :: firebase order by key descending 
Javascript :: how to make apk of react native app 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =