Please I can't find my mistakes with Profile Lookup!

Tell us what’s happening:
I tried everything, reset a couple times, and this will not run…
Is it still “undefined”, I don’t see a problem?

Your code so far

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 (firstName === contacts[i].firstName)
        if (contacts[i].hasOwnProperty(prop) === true) {
            return contacts[i][prop];
        } else {
            return "No such property";
return "No such contacts";
// Only change code above this line
//  moved return "No such contacts";
// Change these values to test your function
lookUpProfile("Akira", "likes");

Your browser information:

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

Link to the challenge:

I’ve edited your post for readability. 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.


The above return statement is outside of the function, so it creates a syntax error.

I’m back to firstName not defined?

That is because you never declared firstName in your function. Why did you write firstName if it does not have a value?

1 Like

The following question is the reason I used it:
the function should check if name is an actual contact’s firstName and the given property(prop) is a property of that contact
I worked on it and reset so many times it does not Run the Test.
I’m past firstName not defined, and lost it with “Bob’s” potato and number.

Thank You randelldawson, for your guidance.
I’m going to take a break from this, change what I’m working on and come back to this later (refreshed). :slight_smile:

If you need any more help. make sure to repost your latest code in a reply and please use the 3 back ticks on the line before and after the code you paste into the post.

1 Like

Thank You !
I will with a fresh new start after my break. :wink: