Basic JavaScript: Profile Lookup - help me!

omg i fixed it look!
’ ’ ’
function lookUpProfile(name, prop){

// Only change code below this line

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

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

     if (contacts[i].hasOwnProperty(prop)) {

         return contacts[i][prop];

     } else {

         return "No such property";

     }

 } }

     return "No such contact";

’ ’ ’
i just had to take (return “No such contact”:wink: outside the loop so loop can still go all over the other contacts !! thanks

Congratulations! I’m glad I could help.

1 Like

the reason’s is the return of if condition bcs it must return array
if (contacts[i].hasOwnProperty(prop)) {

     return contacts[i][prop];