JS Fiddle
I realize there's already a pretty good answer. I was in the midst of doing my own before I realized, but in the interest of being complete this allows you to put in arrays in any order and is a function, meaning if you have to do this with a few different arrays this should allow you to do it with much less code.
It creates a function called pyramidArrange and when you pass it three arrays, it first sorts them for length and then performs the calculations returning a Set Objectof all the values. A Set Object you can think of as an array that only allows one of each value stored inside of it. It also gives you the easy ability to check what's within it by using SetObj.has(value)
var myObj = {
classes2: ['.classI'],
classes1: ['.classA', '.classB'],
classes3: ['.class1', '.class2', '.class3'],
}
FirstArray = myObj.classes1;
SecondArray = myObj.classes2;
ThirdArray = myObj.classes3;
pyramidArrange(FirstArray, SecondArray, ThirdArray);
function pyramidArrange(firstArr, secondArr, thirdArr) {
var ourSet = new Set();
var ourArrays = [{
array: firstArr,
length: firstArr.length
}, {
array: secondArr,
length: secondArr.length
}, {
array: thirdArr,
length: thirdArr.length
}];
ourArrays.sort(function(a, b) {
return a.length - b.length;
});
for (let val of ourArrays[0].array) {
for (let val2 of ourArrays[1].array) {
for (let val3 of ourArrays[2].array) {
ourSet.add(val + val2 + val3);
}
}
}
return ourSet;
}