I've got an array of random numbers 1-10 and would like to create 10 arrays, each of them starting with a number from the random array like so:
const shuffled = [3, 6, 8, 2, 7, 1, 10, 4, 9, 5];
let rGrid = [];
// populate arrays
for (let x of shuffled) {
rGrid[x-1] = new Array(10);
rGrid[x-1][0] = x;
}
console.log(rGrid);
So ultimately I would like:
array1: 3,,,,,,,,,,,,
array2: 6,,,,,,,,,,,,
array3: 8,,,,,,,,,,,,
etc.
The code I have places ordered numbers 1-10 as first elements of arrays:
array1: 1,,,,,,,,,,,
array2: 2,,,,,,,,,,,
array3: 3,,,,,,,,,,
Please advise. Here's a code pen: http://codepen.io/wasteland/pen/QdvwJj?editors=1010