Profile Lookup// plz help!

Profile Lookup// plz help!
0

#1

Tell us what’s happening:
I saw ppl use for loop and I wonder if I need that. I think I have a mistake in naming the prop search and it’s value.

any hints plz!

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
if (name=="firstName"&&prop==contacts.hasOwnProperty("")){
  return prop[value];
}else if(name!=="firstName"){
  return "No such contact";
}else if(prop!==contacts.hasOwnProperty("")){
  return "No such property";
}
// Only change code above this line
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/profile-lookup


#2

You need to first write out an algorithm in plain language containing the actual steps you would take to produce the required outcome in all test cases.

Remember, contacts is an array of objects, so you are going to need to iterate through it in some way to check each object’s properties against the arguments given in the function.


#3

What is the point here? Are you trying to determine if contacts has its own property prop? If this is the case, then replace this with contacts.hasOwnProperty(prop). This function returns a boolean value.