Created
August 17, 2015 07:52
-
-
Save Oppodelldog/2d531a84069e12ba9d8b to your computer and use it in GitHub Desktop.
Evaluate all possible combinations of array items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = ["a","b","c","d","e","f","g","h","i","j"]; | |
for(i = 0; i <= Math.pow(2,arr.length)-1; i++){ | |
var mask = i; | |
console.log("-------------------------------------" + mask); | |
var combination = ""; | |
for(y=0; y<arr.length; y++){ | |
if((mask & Math.pow(2,y)) == Math.pow(2,y)) combination += " " + arr[y]; | |
} | |
console.log(combination); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment