For Each loop in JavaScript are making me mad
<p>My problem is pretty simple. 
I'm trying to update a list of objects (localDatz) with another list of objects received after an AJAX request (data). 
So It consists in two loops.. But when I try to update two objects, only one object is updated. There is something I really don't understand.
Any help ?</p>

<pre><code>    // fetch the localdata first
            var localData = getAll();

// Loop through my 'localData'
$.each(localData.features, function(index,feature){

        // Loop through the new data that are received
        $.each(data.features, function(){
            newFeature = this;

            if (feature.properties.id==newFeature.properties.id){

            // i think here is the problem..but can't figure out how to fix it
            // I remove the old feature and push the new one
            localData.features.splice(index,1);                                                                   
            localData.features.push(newFeature);


            }

    });

});
</code></pre>
