I have an array of objects saved in localstorage.
Here is a sample of the array of objects:
[{"mls":"1266159","addr":"13556 S TUSCALEE , Draper, UT 84020","price":"$1499000","description":"Bds: 7 | Ba: 7 | 10376 Sqft."},{"mls":"1279829","addr":"12927 S SALZ , Draper, UT 84020","price":"$779000","description":"Bds: 4 | Ba: 4 | 5857 Sqft."},{"mls":"1279960","addr":"14226 S CANYON VINE E, Draper, UT 84020","price":"$1899000","description":"Bds: 7 | Ba: 8 | 10015 Sqft."}]
I have written a function to get the array, then run an "each" loop to iterate over the objects and return all objects in the array, in the specified format.
Function:
function getReportStore() {
var rs = localStorage.getItem("reportStore");
//console.log("Report Store: "+rs);
if((rs != null) && (rs != '')){
var r = JSON.parse(rs);
$.each(r, function (k, v) {
return "MLS: "+v.mls+" Address: "+v.addr+" Price: "+v.price+" Description: "+v.description;
});
}
}
Trying to call function, and return the data into a variable...
var p = getReportStore();
Now use the variable...
var report = "Properties Viewed: " + p;
console.log("The Report: "+report);
The problem, is that when I try and execute the function in order to use the returned objects as a variable, it comes back as "undefined".
Thank you in advance for your suggestions/assistance/guidance/etc!