Profile Lookup I need help!

Profile Lookup I need help!
0.0 0


I am stuck can someone please explain to me what I am doing wrong?

var contacts = [
“firstName”: “Akira”,
“lastName”: “Laine”,
“number”: “0543236543”,
“likes”: [“Pizza”, “Coding”, “Brownie Points”]
“firstName”: “Harry”,
“lastName”: “Potter”,
“number”: “0994372684”,
“likes”: [“Hogwarts”, “Magic”, “Hagrid”]
“firstName”: “Sherlock”,
“lastName”: “Holmes”,
“number”: “0487345643”,
“likes”: [“Intriguing Cases”, “Violin”]
“firstName”: “Kristian”,
“lastName”: “Vos”,
“number”: “unknown”,
“likes”: [“Javascript”, “Gaming”, “Foxes”]

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (firstName === firstName && contacts[i].hasOwnProperty(prop)){
if (contacts[i].firstName !== firstName) {
return “No such contact”;
} else
return"No such property";
// Only change code above this line

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


U first check firstName against firstName so it is always true unless it is NaN

console.log(NaN !== NaN);

So u want to check against current position in for loop like
contacts[i].firstName === firstName

So if that is not satisfied after whole loop through contacts,
u return 'No such contact’
Vice versa if it exist u check does it have own property, and to return control to caller, cause there is unique contact
And at the end it need to looks something like:

var exist = false;

for (var i = 0; i < contacts.length; i++) {
if ( contacts[i].firstName === firstName ){
     exist = true;
     if ( !contacts[i].hasOwnProperty(prop) )
            return 'No such property';



if ( !exist )
   return 'No such contact';

*i didn’t lookup in challenge so doesn’t know if this will satisfy it
it is projected from ur code