Finding properties in objects (profile look up hints)

I’m trying to accomplish the profile lookup challenge by working out bits of code to understand the problem bit by bit. I’m stumped by trying to evaluate properties within objects. Currently I have a function that looks like this:

function lookUpProfile(prop) {
  for (i = 0; i < contacts.length; i++) {
    if (contacts[i].hasOwnProperty(prop)) {
      console.log('has property');
    } else {
      console.log('has no property');

Right now, this function does nothing when called. I’m unsure why. I followed similar syntax when looking for names with success.

function lookUpProfile(name) {
  for (i = 0; i < contacts.length; i++) {
    if (name == contacts[i]['firstName']) {

I can’t figure out why one line of code evaluates true and the other doesn’t evaluate at all.

Actually, neither of the functions you show above will do anything, because in both functions, you are missing a closing } for your for loop.

It’s amazing how easily the simplest things get overlooked.