Created
June 11, 2017 18:52
-
-
Save dashcraft/aadaa76c1d6173192364d3c28be3d610 to your computer and use it in GitHub Desktop.
sample solution for obj prop lookup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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