I have this array:
var arr1 = [
{"user":"dan","liked":"yes","age":"22"},
{"user":"sarah","liked":"no","age":"21"},
{"user":"john","liked":"yes","age":"23"},
];
I'd like to create a new (sub)array of that array, containing only the likes of the users.
so it would look like this:
var arr2 = [
{"dan":"yes"},
{"sarah":"no"},
{"john":"yes"},
];
I tried:
var arr2 =[];
for(var i in arr1){
arr2.push({[i[user]]:i[liked]});
}
it needs a tweak, ideas?