Profile Lookup Challenge Difficulties

Tell us what’s happening:
I am embarrassed to admit that I am over eight hours into this challenge, but here I am anyway…

Looking at other students questions concerning this challenge, it seems to me that everyone is attempting to use array accessing methods on objects, though none of the responses mention this. The only way I have been able to get to the object key ‘firstName’ has been through assigning a variable to Object.keys(contact), where ‘contact’ is a variable representing one iteration through the ‘contacts’ list.

Am I totally off on this? I otherwise think I am close, but cannot figure out how to access the value of the key ‘firstName’ in order to test it against the name entered into function(name)?

Can someone give me some feedback?

  **Your code so far**

// Setup
var contacts = [
      "firstName": "Akira",
      "lastName": "Laine",
      "number": "0543236543",
      "likes": ["Pizza", "Coding", "Brownie Points"]
      "firstName": "Harry",
      "lastName": "Potter",
      "number": "0994372684",
      "likes": ["Hogwarts", "Magic", "Hagrid"]
      "firstName": "Sherlock",
      "lastName": "Holmes",
      "number": "0487345643",
      "likes": ["Intriguing Cases", "Violin"]
      "firstName": "Kristian",
      "lastName": "Vos",
      "number": "unknown",
      "likes": ["JavaScript", "Gaming", "Foxes"]

function lookUpProfile(name, prop) {

for (let i = 0; i < contacts.length; i++) {
  let contact = contacts[i];   //placeholder variable
  let objNest = Object.keys(contact);
  let objName = objNest[0];
  if (name === objName[name]){    
     if (prop === objNest[prop]){
      for (let j = 0; j < objNest.length; j++) {
      if (name === objNest[j].firstName && objNest[j].hasOwnProperty(prop)) {
      return contact[j].hasOwnProperty(prop);
      else return "No Such Property"
  else return 'No Such Contact';


lookUpProfile("Akira", "likes");
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0

Challenge: Profile Lookup

Link to the challenge:

Hi @SevenRoot ,

Try doing a console.log of “contact”, “objNest”, “objName”, “objName[name]

You will be able to see the problem with this.

Note that capitalization is important

No such contact

1 Like

Oh, I’ve been console.logging things like that for hours. That is where I got the idea that I just needed to find the right syntax for accessing contacts>firstName>name, because ‘objName’ gives me a list of the object keys, objNest brings me to the key values “firstName”.
I know that objName[name] returns undefined. Is there a syntax that would access the name to run test?

Thank you for your input…

Why do you need that? The firstName is a string and therefore does not have a name property.

Sorry if that was too short hand again.
In my understanding of the challenge, a name is entered into the function ‘lookUpProfile’. I then need to check that given name against the available first names inside each object inside of the array ‘Contacts’. Therefore, I am attempting to access the array(‘Contacts’)>the object key(‘firstName’)>name(the value of the key ‘firstName’) to compare it against the ‘name’ entered into the function.

I completely recognize that using ‘name’ in objName[name] is not a reference to something that exists, more of a placeholder for some proper syntax I have yet to discover.

Does that make my question clearer?

This isn’t quite what you are supposed to be doing.

You need to check each object in the contacts array until you find an object in the contacts array that has a matching firstName property.

You access element of the contacts array with their index via bracket notation. Once you get the element, you have an object and can access it’s properties with dot or bracket notation.

1 Like

Okay, but to access the those object elements of the contacts array with their index, I am thinking I need to use Object.keys(). It is my understanding that this is the method for iterating through objects. Is that correct?

Have you used Object.keys() to get elements of an array in previous challenges?

The hardest part of this challenge is understanding that you are working with an array were each element is an object.


let myArray =[1, 2, 3];

How do you get an element from this array?

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.