Answers for "how to print all combinations of a number in array in javascript"

0

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');
Posted by: Guest on August-06-2020
-1

get combinations of two js

var array1=["A","B","C"];

var array2=["1","2","3","4"];

console.log(array1.flatMap(d => array2.map(v => d + v)))
Posted by: Guest on October-13-2020

Code answers related to "how to print all combinations of a number in array in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language