Profile Lookup can anyone explain why

Profile Lookup can anyone explain why
0.0 0

#1

Tell us what’s happening:
I don’t know why my code doesn’t work
can anyone please tell me where I did mistake.

Your code so far

//Setup
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 (i=0;i<contacts.length;i++)
  {
    for (j=0;j<contacts[i].length;j++)
  {
     /* if (firstName == contacts[i].firstName && prop == contacts[i][j])
          { return contacts[i][j];  }
        else if ( firstName == contacts[i].firstName && prop != contacts[i][j])
        {return "No such property";}
        else if ( firstName != contacts[i].firstName && prop == contacts[i][j])
        {return "No such contacts";} */
    
    
        if ( firstName != contacts[i].firstName)
          { return "No such contacts"; }
        if ( prop != contacts[i][j] )
          { return "No such property"; }
        if (firstName == contacts[i].firstName && prop == contacts[i][j])
          { return contacts[i][j];  }
        
          
           
  }
      
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36.

Link to the challenge:


#2

:v Oh. I should use hasOwnProperty(prop) instead