Rafiq Muntaqim Rafiq Muntaqim - 24 days ago 8
Javascript Question

How would you loop through array of coordinates?

How would you loop through array of coordinates using javascript. For example. I have an array in the following format:

[[150, 0], [0, 200], [300,200]]


for each set of coordinates i'd like to add them to a variable called

var pt;


What would be the best way to accomplish this?

Answer
var pt;
for(var i=0, n=youArray.length; i<n; i++){
 pt = youArray[i][0]+','+youArray[i][1];
}