# Help with Profile Lookup Challenge

**URL:** <https://forum.freecodecamp.org/t/help-with-profile-lookup-challenge/97433>\
**Category:** General\
**Created:** [March 16, 2017, 11:09pm UTC](https://forum.freecodecamp.org/t/help-with-profile-lookup-challenge/97433 "2017-03-16T23:09:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![apandey09](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@apandey09](https://forum.freecodecamp.org/u/apandey09)\
**Post date:** [March 16, 2017, 11:09pm UTC](https://forum.freecodecamp.org/t/help-with-profile-lookup-challenge/97433/1 "2017-03-16T23:09:46Z")

</div>

Hey all,

So I’m currently attempting the Profile Lookup challenge. I started it last night, but couldn’t get anywhere. However, I’ve made some progress today thanks to reading some of the previous threads of users who were in the same situation as I am. Plus, the hints offered on the Profile Lookup challenge guide were also helpful.

Here is my code as it is right now:

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

```

So far, I have been able to complete the last two parts of this challenge:

“Kristian”, “lastName” should return “Vos”  
“Sherlock”, “likes” should return [“Intriguing Cases”, “Violin”]  
“Harry”,“likes” should return an array  
(Y) - “Bob”, “number” should return “No such contact”  
(Y) - “Akira”, “address” should return “No such property”

I know I’m on the right track and that I need to tweak something in my current code in order to meet all the criteria for this challenge. However, I’m not sure which part(s) I need to tweak in order to accomplish that. What suggestions or recommendations would you like to offer that will guide me in the right direction?

Thanks to all who responded. I appreciate your input!

---

<div class="post-metadata">

**Author:** ![mblood](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@mblood](https://forum.freecodecamp.org/u/mblood)\
**Post date:** [March 16, 2017, 11:25pm UTC](https://forum.freecodecamp.org/t/help-with-profile-lookup-challenge/97433/2 "2017-03-16T23:25:52Z")

</div>

You’ll need to change `contacts[i].prop` to `contacts[i][prop]`.

When you type `contacts[i].prop`, you’re actually getting a property of that object called `'prop'`. That would be like calling `contacts[i]['prop']`.

Whenever you want to get a property name that is a variable, in this case `prop`, you need to use bracket notation instead of dot notation.

---

<div class="post-metadata">

**Author:** ![apandey09](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@apandey09](https://forum.freecodecamp.org/u/apandey09)\
**Post date:** [March 17, 2017, 2:01am UTC](https://forum.freecodecamp.org/t/help-with-profile-lookup-challenge/97433/3 "2017-03-17T02:01:06Z")

</div>

That did the trick! Thanks for your help and your explanation.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 9:42am UTC](https://forum.freecodecamp.org/t/help-with-profile-lookup-challenge/97433/4 "2021-01-17T09:42:32Z")

</div>


