Updating values in localstorage from ionic view

So i’ve got this piece of code to update the date and time a person leaves in localstorage

$scope.visitorOut = function(id){
var allVisitors = JSON.parse(localStorage["allVisitors"]);
var visitor;
for(var i=0; i<allVisitors.length; i++){
visitor = allVisitors[i];
if (allVisitors[i].id === visitor.id) {
visitor.dateout = new Date();
console.log(visitor.id)
break;
}
}
localStorage["allVisitors"] = JSON.stringify(allVisitors);
};

It updates the ‘dateout’ but for just the same item in localstorage and the console.log displays the same id each time…here’s my html:

        <div class="list">
      <a class="item item-icon-left item-icon-right" ng-repeat="visit in visits | orderBy: '-date'" ng-click="visitorOut(id); closesignout()" ng-hide="visit.hide">
    <i class="icon ion-person"></i>
    {{visit.fname}} {{visit.lname}}
    <i class="icon ion-log-out" ng-click="hideMe(visit)"></i>

i want whener a person clicks on their name, it calls the visitorOut function and updates only their ‘dateout’

I don’t think it’s an Ionic question. Sorry to say, but your code seems messy. The visitor’s variable is undefined, and what’s ivisitor? Your for checks for equals, it’ll never reach its core.