Help with basic JavaScript tutorial

Help with basic JavaScript tutorial
0

#1

This is for the basic javaScript Profile lookup solution. This should work. I have no idea why it isn’t.

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

#2

yeah, i just asked for the hint. I found the solution at the bottom… and what I did is basically the same as the solution. except mine doesn’t have any syntax errors. Please Help!


#3

What does the failing test say?


#4

@dustyhawkins - In your solution, do you understand what happens if the firstname property’s value of the first contact (contacts[0]) does not match the name argument?