I feel like im messing some of the [ ]

Tell us what’s happening:
A lookUpProfile function that takes name and a property ( prop ) as arguments has been pre-written for you.

The function should check if name is an actual contact’s firstName and the given property ( prop ) is a property of that contact.

If both are true, then return the “value” of that property.

If name does not correspond to any contacts then return "No such contact" .

If prop does not correspond to any valid properties of a contact found to match name then return "No such property" .

Your code so far

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){
// Only change code below this line
if(name ==contacts[name].firstName && prop == contats[name].prop)
return contacts[name][prop]
else if(name !== contacts[name]){
return 'No such property';
}else if(name ==contacts[name].firstName && prop !== contats[name].prop)
return 'No such property'
// Only change code above this line

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 12607.82.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.123 Safari/537.36.

Challenge: Profile Lookup

Link to the challenge:

Welcome, dhobson.

Please fill in the Tell us what’s happening section so that we can know what the problem is.

else if(name !== contacts[name]){
return 'No such property';

This isn’t what you meant to do. If the name of the first item doesn’t match name, then you will return “No such property” and exit.

im confused explain a little bit

There’s actually a bigger problem that I missed because I thought your logic was in a loop.

  • contacts is not an object. It is an array. There is no such thing as contacts[name].
    • You need to look at each of the objects in the contacts array.
  • Once you have that part figured out, you do not want to return ‘No such property’ if a contact does not match the name argument.

so like contacts.name[firstname]

Contacts is an array. contacts.name[firstname] does not exist. contacts.name does not exist.