profileLookupForDummy

Am i right in making a nested for loop to cycle through contact list or does it only need 1 for loop? I’m also planning do the if statement inside of it. my my thought process is if it cycles through the object and find what it is looking for it will then check what other conditions it need to check before it can return.
I’m just lost at the momment, P.S i saw a stat form FCCthat most people spend 7 mins on this problem. I been at it for 2 days :pensive:

Oh and how would i go about checking if the given property ( prop ) is a property of that contact. would it be something like this if(prop == contacts[i][j]), i’m also thinking prop in contacts[i]. But i don’t know if nested for loop is correct tho. i’m taking out the nested for loop seems wrong
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(name, prop){
// Only change code below this line
for(var i=0; i < contacts.length; i++){
for(var j=0; j < contacts[i].length; j++){


}

}

// Only change code above this line
}

lookUpProfile("Akira", "likes");
**Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36.

Challenge: Profile Lookup

Link to the challenge:

With some adjustments it’s possible to use nested loop here. Notice however it’s not so easy to loop through object properties, if console.log(contacts[i].length) would be added inside of loop, it would print out to console undefined. It would require to take out object keys to an array and only after that loop through them.

Objects have hasOwnProperty method that can be used to check just that - if they have certain property. Consider using this method.