I have a function in which I'm scheduling reminders on mobile. I'm building out an array of repeating items and incrementing two properties of each object submitted to the array, everything else in the object stays the same. When I start the first iteration of the loop, it pushes the object into the array as expected, but the second iteration updates the 'reminderId' value INSIDE the array before I ever step into the object or push function while debugging. The 'time\_to\_notify' increments as expected, only the 'reminderId' gets replaced.

On the next iteration it increments and I end up with an array that looks like this:

```
[
0{id: 2, title: "Athens", text: "Test", at: Tue Dec 13 2016 16:00:28 GMT-0600 (CST)}
1{id: 3, title: "Athens", text: "Test", at: Wed Dec 14 2016 16:00:28 GMT-0600 (CST)}
2{id: 3, title: "Athens", text: "Test", at: Thu Dec 15 2016 16:00:28 GMT-0600 (CST)}
]

```

Should look like this:

```
[
0{id: 1, title: "Athens", text: "Test", at: Tue Dec 13 2016 16:00:28 GMT-0600 (CST)}
1{id: 2, title: "Athens", text: "Test", at: Wed Dec 14 2016 16:00:28 GMT-0600 (CST)}
2{id: 3, title: "Athens", text: "Test", at: Thu Dec 15 2016 16:00:28 GMT-0600 (CST)}
]

```

Notice that the dates incremented correctly, but there is an issue with how the 'reminderId' is incrementing and I've been banging my head for hours. 

My code that builds this is below. It's probably something super simple, any help is greatly appreciated.

```
if(isIOS){
      var notificationItem = [];
      var reminderId = -1;
      for(i=0; i < 3; i++){

          var iOSNotification = {};
          if ($scope.scheduledContainer.length == 0 && notificationItem.length == 0) {
            reminderId = 1;
          } else if ($scope.scheduledContainer.length > 0) {
            var convertDate = new Date(time_to_notify);
            convertDate.setDate(convertDate.getDate()+1);
            time_to_notify = convertDate;

          var max = $scope.scheduledContainer.reduce(function(prev, current) {
            return (prev.y > current.y) ? prev : current
          }); //$scope.scheduledContainer contains array items if they alreay exist
            reminderId = ++max.id;
        } else if (notificationItem.length > 0) {
            var convertDate = new Date(time_to_notify);
            convertDate.setDate(convertDate.getDate()+1);
            time_to_notify = convertDate;

          var max = notificationItem.reduce(function(prev, current) {
            return (prev.y > current.y) ? prev : current
          }); //notificationItem is a temp array that contains first time notification repeats
            reminderId = ++max.id;
        }

        iOSNotification = {
          id: reminderId,
          title: mxAppConfig.RegionId,
          text: task.msg,
          at: time_to_notify
        }

        notificationItem.push(iOSNotification);

      }

    }

```