function Case(values){
console.log("values: " + values);
var A = [];
var B = [];
var C = [];
var i = 0;
while(i < values.length) {
A.push(values[i++]);
B.push(values[i++]);
C.push(values[i++]);
}
console.log("A: " + A);
console.log("B: " + B);
console.log("C: " + C);
}
var values = [5, 4, 3, 6, 7 , 8];
Case(values);
values = [5, 4, 3, 6, 7 , 8, 10, 20, 30];
Case(values);
NOTE: values
array should always have the number of elements in multiple of 3 because there are 3 arrays in this case A,B and C.
2
solved javascript array assign to multiple variables