I have an array of several entries with some of them with same name .All entries have location but one is empty.I want to save the same value of location into all entries of the array for same user. How can I do that?
array=[{
user: angelos,
user_id: 121212,
date: 12/12/12,
profile_img: cfdf,
text: nhkjhgjtdkghd,
url: g.htm,
location:Romania
},{
user: angelos,
user_id: 121212,
date: 12/12/12,
profile_img: cfdf,
text: nhkjhgjsdfsadstdkghd,
url: g.htm,
location:""
},{
user: Mike,
user_id: 121212,
date: 12/12/12,
profile_img: cfdf,
text: nhkjhgjtdkghd,
url: g.htm,
location:New York
},{
user: Mike,
user_id: 121212,
date: 12/12/12,
profile_img: cfdf,
text: nhkjhgjsdfsadstdkghd,
url: g.htm,
location:""
}];
First, for each user, store its non-empty location. Then, in the second pass, simply set empty locations based on the stored
user -> locationmap.