Cant figure whats wrong


#1

It says that list function is not created?

    var friends = {
        milena: {
            firstName: 'Milena',
            lastName: 'Petrovic',
            number:+38169686209,
            address: ['Kraljevo', 'Dimitrija Tucovica 10/20', 'Serbia' ]
            },
        bill: {
            firstName: 'Bill',
            lastName: 'Mudonja',
            number: 03352645464,
            address: ['Kraljevo', 'Dimitrija Tucovica 1650/20', 'Serbia' ]
            },
        steve: {
            firstName: 'Steve',
            lastName: 'Jobs',
            number: 032456565677,
            address: ['Kraljevo', 'Dimitrija Tucovica 15/20', 'Serbia' ]
            }  
    
    };
    
var list = function(friends) 
{
    for (var keys in object)
    {    console.log(keys);
            };
};

#2

This properties should be as string value:

...
number: "+38169686209",
...

UPDATED
Also you have problem with for / in loop:

 for (var keys in object) { ... }

object is not defined, should be _ friends_ instead


#3

Fixed that but is still says that function list is not created


#4

You need rename parameter friends to object or object in loop to friends.

var list = function(object)  {
    for (var keys in object) {    
       console.log(keys);
    }
};

list(friends); // don't forget to call the function

Function takes one parameter, so you can work with it inside the function


#5

thx it helped, and i got it now


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.