I am trying to write a common function to access object properties as parameters, but i keep getting "undefined". here is my code
var users = [{
"id": 1,
"first_name": "Fredelia",
"last_name": "Tanman",
"email": "[email protected]",
"gender": "Female"
}, {
"id": 2,
"first_name": "Sigmund",
"last_name": "Maryska",
"email": "[email protected]",
"gender": "Male"
}, {
"id": 3,
"first_name": "Axel",
"last_name": "Stangoe",
"email": "[email protected]",
"gender": "Male"
}, {
"id": 4,
"first_name": "Mariana",
"last_name": "Danneil",
"email": "[email protected]",
"gender": "Female"
}, {
"id": 5,
"first_name": "Kira",
"last_name": "Papps",
"email": "[email protected]",
"gender": "Female"
}]
function getProp(prop){
return users.map(function(person){
return person.prop;
})
}