Profile Lookup troubles

Can anyone please tell me what is wrong with my code? I have been sitting here for a few hours trying to figure out why I can’t pass.


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

// Only change code above this line
}

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate 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.

Note: Backticks are not single quotes.

markdown_Forums

Thanks a bunch for the quick reply. I refactored my code and adjusted the return statement like you suggested, works great now!