Skip to content

Commit

Permalink
Update add-to-favorites.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinaHranovska committed Feb 14, 2024
1 parent 062961e commit 7745e7a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/js/add-to-favorites.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function getIDModul(e) {
const liElement = e.target.closest('.js-id');
if (liElement) {
cardID = liElement.dataset.id;
if (storedArrayAdd.includes(cardID)) {

if (updateLicalStorage().includes(cardID)) {
refs.removeFromFavoritesBtn.classList.remove('hidden-btn');
refs.addToFavoritesBtn.classList.add('hidden-btn');
} else {
Expand Down Expand Up @@ -56,3 +57,7 @@ function updateGallery() {
cardToRemove.remove();
}
}

function updateLicalStorage() {
return localStorage.getItem('addKeyID');
}

0 comments on commit 7745e7a

Please sign in to comment.