Profile Lookup - Don´t know what is wrong with my code

Profile Lookup - Don´t know what is wrong with my code
0.0 0

#1

Seems like it fails to pass for:

“Kristian”, “lastName” should return “Vos”
“Sherlock”, “likes” should return [“Intriguing Cases”, “Violin”]
“Harry”,“likes” should return an array

Thanks

function lookUpProfile(firstName, prop){
// Only change code below this line

for(var i = 0; i < contacts.length; i++){
if(contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)){
return contacts[i].prop;
}else if(contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop) === false){
return “No such property”;
}else {
return “No such contact”;
}

}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile(“Akira”, “address”);


#2

There is a difference between

obj.prop

and

obj[prop]

First one is equivalent to saying

obj['prop']

that is you are looking for a property named ‘prop’.

In second one, prop is a variable and its value will be looked up.

var prop = 'firstName';

// These are identical
obj[prop];
obj['firstName'];
obj.firstName;

I think this is enough for you to find the problem.