Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
614 B
1
Indexable
Never
function lookUpProfile(name, prop){
// Only change code below this line
    

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