2
I have the following code:
var newLat = markerElem.getAttribute('lat');
var newLng = markerElem.getAttribute('lng');
var locations = [
{lat: newLat, lng: newLng}
]
I want to take the values of the variables newLat
and newLng
and store them within the array locations
as values of their respective indices.
EXAMPLE
I want the variable values passed newLat
and newLng
for the array indexes lat
and lng
, being like this:
var newLat = 123;
var newLng = 321;
var locations = [
{lat: 123, lng: 321}
]
I don’t understand can you explain better?
– Ricardo Pontual
Can you improve the explanation? You want to add variables to the array or create an array of variables?
– Lucas Brogni
Let me give you an example to make it clear
– Higor Cardoso
If your wish is to add to the do 
 array;
locations.push({ lat: newLat , lng: newLng});
javascript will add a new input to your array and then to retrieve it just go through it.– Lucas Brogni
Lucas Brogni, your code worked, I just had to pass the values to float. Reply to my post with this comment to mark it as solved.
– Higor Cardoso
@Higorcardoso answered there. Hehe
– Lucas Brogni