Skip to content

Instantly share code, notes, and snippets.

@dashcraft
Created June 11, 2017 18:52
Show Gist options
  • Save dashcraft/aadaa76c1d6173192364d3c28be3d610 to your computer and use it in GitHub Desktop.
Save dashcraft/aadaa76c1d6173192364d3c28be3d610 to your computer and use it in GitHub Desktop.
sample solution for obj prop lookup
function lookUpProfile(firstName, prop){
// Only change code below this line
var match = contacts.filter(function(x){
return x.firstName == firstName;
});
console.log('match',match[0]);
if(match[0]){
if(match[0].hasOwnProperty(prop)){
return match[0][prop];
}
else{
return "No such property";
}
}
else{
return "No such contact";
}
// Only change code above this line
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment