A newbie here, while trying to learn the concept of Profile Lookup, after adding these codes,

function lookUpProfile(name, prop){
// Only change code below this line
    for (var x = 0; x < contacts.length; x++) {
        if (contacts[x].firstName === firstName) {
            if (contacts[x].hasOwnProperty(prop)) {
                return contacts[x][prop];
            } else {
                return "No such property";

    return "No such contact";
// Only change code above this line

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

An error “firstName is not defined”, so I added “var name = firstName;” still error, only “var firstName = name;” will be accepted, why?

Thanks for the help in advance.

This line below, what are you trying to compare with? You haven’t set firstName variable so it’s undefined. Therefore you are getting that error.

if (contacts[x].firstName === firstName)

Read this instruction carefully.

The function should check if name is an actual contact’s firstName

You are already given a name parameter in the function, use that to compare with instead of undefined firstName.

sorry for my bad understanding of English,

How should i compare


what should be put in the first place, what should be second?

No Problem.

What I meant was if (contacts[x].firstName === name)

finally, got it…thanks