JS Lookup - something is off

I’m redoing this exercise. It seems like all is okay. The function is not returning the value of the property, though I logged it out (contacts[i][prop]) and looks fine.

for(let i = 0; i < contacts.length; i++) {  
    if(contacts[i].firstName !== name) {
      return 'No such contact'
    }
    if(contacts[i] !== prop) {
        return 'No such property'   
      }
    if(contacts[i].firstName === name && contacts[i] === prop) {
      return contacts[i][prop]
    }
  }//for

With your current logic, your for loop only iterates through the first element in contacts before returning a value. As soon as a return statement is executed, the function is exited (regardless if the loop completed). You have other issues too. You need to think about what contacts[i] represents. You compare it to prop in your second and third if statements, but you should probably console.log each to see what you are really comparing.

I’m trying to understand the data flow.

for(let i = 0; i < contacts.length; i++) {
  if(contacts[i].hasOwnProperty(prop) && name === contacts[i].firstName) {
    return contacts[i][prop]
  };
  if (name !== contacts[i].firstName && (contacts[i].hasOwnProperty(prop) || contacts[i].hasOwnProperty(prop) === false)) {
  };
  if (name === contacts[i].firstName && (contacts[i].hasOwnProperty(prop) === false)) {
    return 'No such property'
  };
}//for
return 'No such contact'

One of the returns is placed outside of the for loop so if it is the case that there is No such contact, then it will not impact the return of No such property?

This isn’t where the semicolon usually goes. Putting it there would break an if-else statement. You shouldn’t put it there.

Correct. Code written after the loop body will be executed after the loop body, unless the function has already returned.