JavaScript loop stops on "localStorage.removeItem"
- by user1755603
Why is the "localStorage.removeItem" stopping the loop? If I remove "localStorage.removeItem" and only leave the "alert", it loops though whole thing, but with "localStorage.removeItem" it stops on the first match.
function removeTask() {
for (i=0; i < localStorage.length; i++){
checkbox = document.getElementById('utford'+i);
if (checkbox.checked == true) {
alert(i);
localStorage.removeItem(localStorage.key(i));
}
}
printList();
}