HELP Profile Lookup

HELP Profile Lookup
0

#1

Not sure how to even start this one…can anyone help?

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

// 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 (Macintosh; Intel Mac OS X 10.12; rv:57.0) Gecko/20100101 Firefox/57.0.

Link to the challenge:


#2

You need to break this problem in to smaller pieces and figure out how to solve each piece first.

Some things to think about and questions to ask yourself:

  1. How are you going to iterate through the contacts array?

  2. The challenge wants you to check if the firstName function argument is an actual contact’s firstName.

  3. How would you reference a specific contact’s firstName value? If the firstName was a match, how would you check if that specific contact has a property which matches the function’s prop argument?

These are a few questions to get you thinking about how to approach the project. I recommend trying to write out an algorithm in plain language before attempting to write any code. If you get stuck, reply back to this post and paste your most recent version of the code into the post. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.