Profile lookup exercise

Can anyone help understand why the following function is not working when resolving the profile lookup challenge

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

// Only change code above this line

console.log(lookUpProfile("Akira", "lastName"));

please add more infos; what’s the challenge link? what do the tests say?

You’re not checking every contact in the contacts array, only the first. You should check every contact in the array before returning "No such contact".

Your first conditional is testing if the entire array of objects has the property (which won’t work), not the current object inside the array you’re iterating through.

@Umurerwa08, you are missing something here, try to find out