Profile Lookup help needed! SOLVED!

Profile Lookup help needed! SOLVED!
0

#1

Hey guys, I’ve been coding now for the past week everyday and I’m exhausted! I’ve been stuck on this question for a while now and I can’t see the problem in my logic, could someone look over it and point it out to me please?That would help me out heaps.

I’m done for a few hours, can’t look at the screen anymore…

Thanks FCC community

:v: out!

function lookUpProfile(firstName, prop){
// Only change code below this line
  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) {
      return "No such contact";
    }
    else {
      return "No such property";
    }
    
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");

#3

Hint - Since you have return statements for all conditions on the FIRST iteration of your for loop, it will not be able to continue to check further in the array, which means the contact could just be farther down in the array.