I'm trying to loop throught all my current localStorage items, but I cannot get to make it work properly, always last item is missing, not sure what else it could be.
function sortObject() {
for(let i = 0; i < localStorage.length; i++) {
if(localStorage.getItem(i) !== null) {
let retrieveData = localStorage.getItem(i);
let retrieveObject = JSON.parse(retrieveData);
console.log(retrieveObject.index);
}
}
}
Output:
SortObject()
1
undefined