Profile LookUp Stuck

Hi guys!

I’m stuck on the Profile LookUp Challenge : Here
Could anyone tell me where is my mistake, please? I’ve check different solutions and posts, but I still can’t explain what’s wrong…
Also, is there any way to debug our code? (Like using spies, or at least see what return our function for a given property).

Thank you for your help :slight_smile:

//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(name, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++){
  if (contacts[i]["firstName"] == name) {
    if (contacts[i].hasOwnProperty(prop) == true){
      return contacts[i][prop];
    } else {
      return "No such property";
    }  
  } else {
    return "No such contact";
  }
}
// Only change code above this line
}

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

Thank you so much @camperextraordinaire !
Yes, because of my return it couldn’t go further than the 1st contact ^^’
Also thank you for explaining how to debug :slight_smile: