Here’s a function i’m having trouble with the foreach loop traverses just fine but i’m having trouble removing item from localStorage.
function removeFromLocalStorage(taskItem) {
let tasks;
if (localStorage.getItem("tasks") === null) {
tasks = [];
} else {
tasks = JSON.parse(localStorage.getItem("tasks"));
}
tasks.forEach((task, index) => {
if (task === taskItem) {
tasks = localStorage.removeItem(task);
}
});
}