Profile lookup [ code comparison ]

Profile lookup [ code comparison ]
0.0 0

#1

Hi, someone kindly have a look at this and help figure out why the first code block didn’t work but the second one did?

First Block

function lookUp(firstName, prop) {
    for (var i = 0; i < contacts.length; i++) {
          if(firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)){
            return contacts[i][prop];
          } else if (firstName !== contacts[i].firstName || contacts[i].hasOwnProperty(prop)) {
            return "No such contact";
          } else if (firstName === contacts[i].firstName || !contacts[i].hasOwnProperty(prop)) {
            return "No such property";
          }
        }
}

Second Block

function lookUp( firstName, prop ) {
  for( var i = 0; i < contacts.length; i++ ) {
    if (firstName == contacts[i].firstName ) {
      if ( contacts[i].hasOwnProperty( prop ) ) {
        return contacts[i][prop];
      } else {
        return "No such property";
      }
    }
  }
  return "No such contact";
}