I am currently working on a project using geolocation. Every 30 seconds, the current location was retrieved from GeoLocation and saved to LocalStorage. I want to concat the stored objects into an array. How do I do this?
const lastIndex = localStorage.getItem("lastIndex");
const endLocation = JSON.parse(localStorage.getItem("location"+lastIndex));
let map = [];
for(let i = 0 ; i <= lastIndex ; i++) {
map.concat(JSON.stringify(localStorage.getItem("location"+i)));
localStorage.removeItem("location"+i);
};
In other words, I want to return a new object by putting the location object through the map array.
For example - map = [{"lng" : "37.12345", "lat" : "13.12345", "timestamp" : "12141251121212"},
{"lng" : "37.12345", "lat" : "13.12345", "timestamp" : "12141251121212"},
{"lng" : "37.12345", "lat" : "13.12345", "timestamp" : "12141251121212"} ]
But what comes out is null, what should I do?
