Can't .fill array with values made with Math.random

Hello, so i’ve conceived this line:
array.fill(Math.ceil(Math.random() * 6), 0, 5);
Yet it shows empty array when i log it into console …

if you look up how array.fill works, it only mutates the values in an array, it does not change the array’s length. So if the array is empty to begin with, it will remain empty.

(Google this: MDN array.fill and read about half-way)

1 Like