Can someone assist me with the property five.myArraysCombined
?
I want this property to consist of just one array (as it currently does in the fiddle) and I need to ensure that no numbers are added together. Each number in the array should not exceed 20, similar to the other arrays.
For instance, if we have these five arrays:
five.myArray1 = [7,2,9,19,3];
five.myArray2 = [6,18,8,1,7];
five.myArray3 = [7,19,4,8,2];
five.myArray4 = [11,9,1,14,5];
five.myArray5 = [3,18,8,9,2];
Then when combined, the arrays would look like this:
five.myArraysCombined = [7,2,9,19,3,6,18,8,1,7,7,19,4,8,2,11,9,1,14,5,3,18,8,9,2];
Code Snippet :
function theNumberClass() {
this.myArray = [[],[],[],[],[]];
this.myArraysCombined = [];
}
var five = new theNumberClass();
function prePickNumbers(objName, theNum, theSumNum, theMaxNum, theMinNum) {
var zzz = [];
for (var x = 0; x < theNum; x += 1) {
pickNumbers(objName.myArray[x], theNum, theSumNum, theMaxNum, theMinNum);
zzz += objName.myArray[x];
}
objName.myArraysCombined.push(zzz);
}
prePickNumbers(five, 5, 40, 20, 1);
My recent attempt involved using var zzz
and pushing it to the property, but it sometimes adds up the numbers in the array, which is not desired.
I've also experimented with various approaches utilizing .concat()
, but it has resulted in converting it into a string and occasionally adding up the numbers as well.