Stuck on Profile Lookup

Stuck on Profile Lookup
0.0 0

#1

I just started on this question and I’m a little stuck. I kind of froze and not sure if the things I was and currently doing was correct. I shorten it down so I can start off somewhat fresh but what am I doing wrong and what I should do?

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(firstName, prop){
// Only change code below this line
 
  for (var i = 0; i < contacts.length; i++) {
    
  }
  
  var values = contacts[prop];
  
  if (firstName == true && prop == true) {
    return values;
  } else if (firstName == false) {
    return "No such contact";
  } else if (prop == false) {
    return "No such property";
  }
  

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

Link to the challenge:


#2

What do you think you are checking with this if statement condition? firstName and prop are arguments passed into the function. If you look at the test cases, none of the values passed in are Boolean values (true or false), so your return values statement will never run.

Also, remember that contacts is an array of objects and not an object, so contacts[prop] makes no sense here. contacts[0] would represent the first object (seen below).

    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    }

and contacts[0].firstName would reference “Akira”.


#3

I don’t think I even read the question right and I’m not really confident on this. Would it be okay if you or anyone else reading this send me some links to help me out?