I'm stuck!


var friends = {};
friends.bill = {
    firstName: "Bill",
    lastName: "Gates",
    number: "1234567897",
    address: ["Washington", "DC", "20005"]
friends.steve = {
    firstName: "Steve",
    lastName: "Jobs",
    number: "9876543214",
    address: ["New York", "Empire State Building", "234"]
friends.alin = {
    firstName: "Alin",
    lastName: "Dinu",
    number: "4522329912",
    address: ["Mizil", "George Raneti", "43"]
var list = function(contactid) {
    for(var option in contactid) {
var search = function(name) {
    for(var key in contactid) {
        if(friends[key].firstName === name) {
            return friends[key];


What are you trying to do?


I just can't understand this functions for objects


That doesn't tell me what you want to know. Do you have a question?


yes what this meansfriends[options].firstName that' s looking for a friends subarray/object which must have name "firstName"?
also I did'nt understand this syntaxfor(var options in friends)?


I passed the checkpoint and didn't understand anything.



friends[options] is one of the persons
then, the firstName property is looked up for that person.

for(var options in friends)

Is a loop. You can read about it here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in

friends = {
    bob: {
        firstName: 'Bob'
// Output from the above print:
// Bob

for (var key in friends) {
    console.log("the current key is: " + key);
    friend = friends[key];
    console.log("the current friend object is: %o", friend);
    console.log("that friends' first name is: " + friend.firstName);
    console.log("%o", friends[key]);
// Output from the above loop (there's only one friend, so only one iteration)
// the current key is: bob
// the current friend object is:  Object { firstName: "Bob" }
// that friends' first name is: Bob


ok but why is working only for firstName this if if(friends[options].firstName === name) {...and if we change it with lastName doesn't work?


If you're looking for a first name then you'll have to use the firstName property

If you're looking for the last name, then compare to the last name

If you're looking for both, look at both


for both the code must look something like if(friends[options].firstName === name && friends[options].lastName === name)?


Do you really expect a person to have the same first and last name?


so then i must input 2 parameters in a function?


That doesn't say anything, those are just words


You can do it in any way you want. It just has to add up to the result you're after. The interpreter does exactly as told, it won't make it right for you. Consider how you would do it manually, the code would be similar to that.