Vote count:
0
I am trying to figure out the best way to split a object that has many key value pairs over 800 points ( they are X and Y coordinates)
I would like to split X into its own array and Y into a separate array so that I can access X alone and Y alone.
Here is the structure of the points and what I have attempted
var path = {
0: [41, -73],
1: [41, -74],
2: [42, -75],
3: [43, -76]
};
for(var key in path)
{
console.log("key " + key + " has value " + path[key]);
}
This will log
key 0 has value 41,-73
key 1 has value 41,-74
key 2 has value 42,-75
key 3 has value 43,-76
I need the first value to be stored in its own array and the second value into another array.
Thanks!
asked 1 min ago
Javascript loop through array keys containing comma seperated values
Aucun commentaire:
Enregistrer un commentaire