Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

generate combinations of values from multiple array javascript

function cartesian(...args) {
    var r = [], max = args.length-1;
    function helper(arr, i) {
        for (var j=0, l=args[i].length; j<l; j++) {
            var a = arr.slice(0); // clone arr
            a.push(args[i][j]);
            if (i==max)
                r.push(a);
            else
                helper(a, i+1);
        }
    }
    helper([], 0);
    return r;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: pass id to reactjs routes 
Javascript :: nodejs remove null from object 
Javascript :: programatic navigation vue router 
Javascript :: how to know if a number has a decimal number js 
Javascript :: js pass object property as a function parameter 
Javascript :: SEQUELIZE OR 
Javascript :: event loop 
Javascript :: mongoose find sort 
Javascript :: laravel react 
Javascript :: clear all intervals js 
Javascript :: how to make one line if in js 
Javascript :: javascript sort multidimensional array 
Javascript :: onclick toggle class react 
Javascript :: JSON Web Token (JWT) set expire time in node js 
Javascript :: element en html and js 
Javascript :: append child at the top 
Javascript :: add new element useState array 
Javascript :: js tab character 
Javascript :: javascript wait async 
Javascript :: javascript pass parameter to event listener 
Javascript :: javascript immediately invoked function expression 
Javascript :: foreach in javascript 
Javascript :: nuxt emit 
Javascript :: react private route 
Javascript :: what indexof in javascript 
Javascript :: how to customize js alert box 
Javascript :: css canvas set aspect ratio 
Javascript :: run a while loop for certain time javascript 
Javascript :: firestore update array 
Javascript :: how to erase spaces from a string javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =