Basic JavaScript - Profile Lookup

Tell us what’s happening:
Describe your issue in detail here.

Your code so far
function lookUpProfile(name, prop) {
for (let x = 0; x < contacts.length; x++) {
if (contacts.firstName === name) {
if (contacts.hasOwnProperty(prop)) {
return contacts[prop];
} else {
return “No such property”;
}
}
}
return “No such contact”;
}
i does not want to work

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Profile Lookup

Link to the challenge:

Remember that when a return statement executes, the function exits regardless if a for loop has completed. Currently, your for loop only ever makes one iteration because you are returning a value during the first iteration. Is that what you want to do?

Hmmm, When I copy and paste your solution in the assignment it passes.

The beginning of the function is already written for you above the “enter code” comment. Maybe make sure the beginning of function is not duplicated. Also, maybe make sure nothing about the array above the line has been changed