I have the following JSON response:
{
"fruits": [
{
"name": "apple",
"prices": [
{
"small": 2,
"medium": 3,
"large": 5
}
]
},
{
"name": "banana",
"prices": [
{
"small": 1,
"medium": 3,
"large": 4
}
]
}
]
}
I want to map it to a new array, so that I can get the "price.small" of each fruit:
$scope.new_data = $scope.fruits.map(function(fruit){
return {
name: fruit.name,
price_small: fruit.prices.small
};
});
But it's not working