I have declared an array variable and I want to push new data but it doesn't work. below is my code
let locations = [
[2.4333,4.45333],
[3.45454,5.222325]
]
here is the code pushing to locations variable
for (var j=0;j<res.length;j++) {
locations.push([res[j]['lat'], res[j]['long']])
//4.3333, 4.33444
}
and this is the code to display
for (i = 0; i < locations.length; i++) {
position: new google.maps.LatLng(locations[i][0], locations[i][1])
}
This is what I'm getting in console log
> Array[]
console.log(locations.length)// 0
Thanks
res[j].console.log(res)after the 'code pushing to locations variable' code. Then you will know if it is an issue with adding, or displayingposition: new ...is not a JS statement.position = ...? What do you mean by "doesn't work" ?