Skip to content

Commit

Permalink
Update 10-favorites.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorSvertoka committed Jan 13, 2024
1 parent 9a945cb commit 91a20da
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/js/10-favorites.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ async function onExercisesCardClick(event) {

const exerciseData = await apiService.getExercisesById(exerciseID);

const local = JSON.parse(localStorage.getItem('exerciseData'));

if (local?.some(item => item._id === exerciseData._id)) {
array = local.filter(item => item._id !== exerciseData._id);
if (array.some(item => item._id === exerciseData._id)) {
array = array.filter(item => item._id !== exerciseData._id);
} else {
array.push(exerciseData);
}
Expand Down

0 comments on commit 91a20da

Please sign in to comment.