Profile Lookup - Stucked for two days

Hello Campers,

I´m triying this challenge for almost 1,5 days.

I would like to solve it with out using for Loops (if it is possible).

after read again and again and again functions, how to access object properties and arrays, how to test objects for properties, I still not finding the answer.

My code until now is:

function lookUpProfile(name, prop){
// Only change code below this line

if (contacts.hasOwnProperty("firstname") && prop["firstname"] === name) {
    return name[prop];
} else if (name !== contacts.hasOwnProperty) {
    return "No such contact";
} else if (prop !== name.hasOwnProperty) {
    return "No such property";
// Only change code above this line

lookUpProfile("Akira", "likes");

Waht I´ve understood is that first of all, I should check thath (name) is a contact´s first name, and I can do this testing objects for properties, right?

Then, if result is true, it should show the result with value “name” (or “prop” I´m not really sure about that, are name and prop arguments or parameters in the function?).

If name is not a contact´s firstname, then returns “Not such contact”, this point is completed with my code.

The other target is to check if (prop) matchs with contact name´s properties (prop is an argument, or is a value, or a propertie?, I´m really confused here). If prop doesn´t match, then “Not such property” must be showed.

I tried to understan why a function has arguments, parameters, properties and values…
and inside a function could be variables and arrays… has someone a link where I can find more info about?

Thanks for your support.

is this an object?

do you have the challenge link?

A loop is required somewhere. Either you need to write a loop yourself to find if/which contact has a matching name, or you need to call a method that internally uses a loop.

I don’t think that you understand the structure of your data.

You have an array of contacts.

Each contact has a firstName and some additional properties.

Your goal is to first find if a contact in the array has a firstName that matches.

Then you need to check if that contact has the requested problem.

a function has arguments and parameters, everything else you have mentioned is data types and data structures and it is what a programming language is made of

you may need to review what each of those is

a function is a reusable piece of code that does stuff parametrically

1 Like