I'm setting an array of IDs as "favourites" in localStorage,
var favIndex=$favourites.indexOf($titleId);
if(favIndex==-1){
$favourites.push($titleId);
$('#fav').addClass('favourited');
}
else{
$('#fav').removeClass('favourited');
}
var favouritesJson=JSON.stringify($favourites);
localStorage.setItem('favourites',favouritesJson);
console.log(localStorage.getItem('favourites',favouritesJson));
If the value is not already in the array it will be added, in the else statement I need to remove $titleId from the array, is this possible and if so how?