Skip to content

combinations across arrays #4

@wanghaisheng

Description

@wanghaisheng

lets say i have three arrays
var arr1 = ['red', 'orange', 'yellow',];
var arr2 = ['car', 'bus'];
var arr3 = ['china'];
how to get the following combinations ,order matters, each result should containe 0..1 element of each arr :

red,car,china
red,china,car
car,red,china
car,china,red
china,car,red,
china,red,car

red,bus,china
red,china,bus
bus,red,china
bus,china,red
china,bus,red,
china,red,bus

orange,car,china
orange,china,bus
bus,orange,china
bus,china,orange
china,bus,orange,
china,orange,bus

orange,bus,china
orange,china,bus
bus,orange,china
bus,china,orange
china,bus,orange,

yellow,car,china
yellow,china,car
car,yellow,china
car,china,yellow
china,car,yellow,
china,yellow,car


yellow,bus,china
yellow,china,bus
bus,yellow,china
bus,china,yellow
china,bus,yellow,
china,yellow,bus

red,car
car,red

red,bus
bus,red

orange,car
car,orange,

orange,bus
bus,orange,

yellow,car
car,yellow,

yellow,bus
bus,yellow,

red,china
china,red,

orange,china
china,orange,

yellow,china
china,yellow,

car,china
china,car,

bus,china
china,bus,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions