ProfileLockup Test

ProfileLockup Test
0.0 0

#1

Code some please help with this task…?

function lookUpProfile(name, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++){
  if (contacts[i].firstName === firstName) {
    if (contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
      } else {
      return “No such property”;
      }
    }
}
return “No such contact”;
// Only change code above this line
}

#2

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


#3

When you return inside a for loop, it exits the function.


#4

Thanx for the note, I do appreciate it!