I'd like to create an coordinates array so that I don't have to manually write 100 pairs of x and y values. I was thinking of using for
loop inside another for
loop, but I couldn't achieve it.
I'd like to make an empty array
, named CoordsArray, and making use of the push method within the most inner for, create an mixed array as follows:
var coordsArray = [
{x:0,y:0},{x:0,y:20},{x:0,y:40},{x:20,y:0},{x:20,y:20},{x:20,y:40},{x:40,y:0},{x:40,y:20},{x:40,y:40}
]
The usage of the above code is for creating three rows of three circles (using D3js) without creating the array manually, because later I'll have to create a 10 rows of ten circles and creating the x and the y position of each one will be very cumbersome. What's the best approach to achieve it? Thanks.