[Solved] Assign values to array javascript

[ad_1]

Because you are initializing an array you could use the Array.from syntax.

This would allow you to declare and initialize your array on the same line.

const value = 300000;
const yaxispoints = value / 10;

const array1= Array.from({length: 11}, (v,i) => i * yaxispoints);

array1.forEach(v => console.log(v));

[ad_2]

solved Assign values to array javascript