Following code should work. It seems that it does not work with forEach function. It works fine with for loop function.
function lookUpProfile(firstName, prop){
// Only change code below this line
var firstNameFound = false;
var propFound = false;
contacts.forEach(function(obj) {
if (obj.firstName === firstName) {
firstNameFound = true;
if (obj.hasOwnProperty(prop)) {
console.log(firstName);
console.log(prop);
console.log(obj[prop]);
propFound = true;
return obj[prop];
}
}
});
if (propFound === false) {
if (firstNameFound === false) return 'No such contact';
return 'No such property';
}
throw 'oops';
// Only change code above this line
}