Sampath
Sampath

Reputation: 65920

Update a property on list of object array and then retrieve the updated list

I have a list of object array as shown below.I need to apply moment.tz("2013-11-18 11:55", "America/Toronto"); to the all the LastUpdate properties and retrieve the updated new array.So how can I do that ?.I can use underscore.js.Thanks in advance.

enter image description here

Upvotes: 0

Views: 41

Answers (1)

Justin Niessner
Justin Niessner

Reputation: 245449

Any reason a simple loop won't work?

for(var i = 0; i < Progress.length; i++) {
    Progress[i].LastUpdate = moment.tz(Progress[i].LastUpdate, 'America/Toronto');
}

OR

     Progress.forEach(function (x) {
        x.LastUpdate= moment.tz(x.LastUpdate, 'America/Toronto');
     });

Upvotes: 1

Related Questions