Following up on this answer for creating an array of specified length, I executed the below to get a corresponding result but filled with random numbers, instead of zeros.>
Short and simple ES6 approach -
// randomly generated n = 4 length array 0 <= array[n] <= 9 var randoms = Array.from({length: 4}, () => Math.floor(Math.random() * 10));
Enjoy!