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.