Profile Lookup Challenge1

Hi, I’m trying to solve this challenge but I’m not sure what wrong with the code.

function lookUpProfile(name, prop){

    var value;

     for(var i=0; i<contacts.length; i++){

        if(contacts[i].firstName===name && contacts[i].hasOwnProperty(prop)){

            value = contacts[i][prop];


        }else if(!(contacts[i].hasOwnProperty(name))){

            value = "No such contact";

        }else if(!(contacts[i].hasOwnProperty(prop))){

            value = "No such Property"



    return value;


what are you checking with this?

I’m checking this " If name does not correspond to any contacts then return the string No such contact ."

is name a possible property name?
it’s not, name has values of Akira, Harry etc, which are not property names

Oh got it thank you!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.