I would like to remove an item from localstorage object:
addToFavs: [{"fav-name":"fav-787336"},{"fav-name":"fav-255890"}]
I stored the information, then I checked if the item found, I should remove it:
/*** getID is the items clicked ***/
var retrievedData = localStorage.getItem("addToFavs");
var parseData = jQuery.parseJSON(retrievedData);
$.each(parseData, function(x,y){
if(y['fav-name'] == getID){
console.log(getID+' found on '+x);
console.log(parseData[x]);
localStorage.removeItem(parseData[x]);
console.log(x+' removed');
} else {
console.log(getID+' NOT NOT found on '+x);
}
}); // end $.each
Thanks in advance
Array.prototype.filter()