JavaScript loop stops on "localStorage.removeItem"
        Posted  
        
            by 
                user1755603
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user1755603
        
        
        
        Published on 2012-10-31T16:49:05Z
        Indexed on 
            2012/10/31
            17:00 UTC
        
        
        Read the original article
        Hit count: 281
        
JavaScript
|local-storage
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();
}
© Stack Overflow or respective owner