How to create a 1D array using Slide bar?

Hello everyone,
I am trying to create a Slider activity for creating a 1D array. As of now, I am just typing them like below.

Array1 = [1, 1, 1, 1, 1]
Array2 = [11,11,11,11,11,11,11,11,11]
Array3 = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]
… etc.
I am hoping that a 1D array will be created if I define the length and elements of the array using the slider bar. The problem is simple, but I don’t understand how to implement this. Elements of array will always be fixed.

Any help will be highly appreciated. Thanks!

Use new Array(length) to create the array, and array.fill(value) to fill it with the value:
Array2 = new Array(9).fill(11)

1 Like

It worked. Thanks a lot!