I have an array of objects as follows:
var lanes = [
{
"name" : "Breakfast Special",
"className" : "breakfast-special",
"sales" : 200,
"redemptions" : 137
},
{
"name" : "Free Danish",
"className" : "free-danish",
"sales" : 300,
"redemptions" : 237
},
{
"name" : "Half Price Coffee",
"className" : "half-price-coffee",
"sales" : 240,
"redemptions" : 37
}];
I want to create an array that contains only numerical values stored for 'redemptions'. I can access values as:
lanes[0].redemptions;
By going through each object using a loop, but I am looking for some efficient way to do that.
I tried this using map function as follows:
var arrayRedemptions = lanes.map(function () {return this.redemptions});
But it's not working. Any help would be appreciated.