Rafiq Muntaqim Rafiq Muntaqim - 1 year ago 73
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 Source
var pt;
for(var i=0, n=youArray.length; i<n; i++){
 pt = youArray[i][0]+','+youArray[i][1];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download