I'm being asked if I created a function called List


#1


when I run the code the error message says
Did you create a function called list?


var friends = {
bill: {
    firstName: "Bill",
    lastName: "Gates",
    number: "(206) 555-5555",
    address: ['405 Sherlock Road', 'Toronto', 'ON', '98052'] 
    },
steve: {
    firstName: "Steve",
    lastName: "Jobs",
    number: "(408) 456-7890",
    address: ['234 Watson Way', 'Minecraft', 'MC', '99999']
    }
};
var list = function (friends) {
    for (var bill in object) {
        console.log('Hello World')
    }
    console.log ("What's Going on here?");
};


#2

You didn't create your list function. Read the instructions!


#3

here's the function I wrote


#4

What should this function do? Please, read instruction.

Updated.
To print console.log('Hello World') you don't need any functions :smile:


#5

so to fix my code for the current part i'm on, all I hit was the Reset Code button


#6

So,

var list = function (friends) {
    for (var bill in object) {
        console.log('Hello World')
    }
    console.log ("What's Going on here?");
};

This code was accepted??


#7

no I reset the exercise to rewrite the code


#8

Here's my code

var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ['405 Sherlock Road', 'Toronto', 'ON', '98052']
},
steve: {
firstName: "Steve",
lastName: "Jobs",
number: "(408) 456-7890",
address: ['234 Watson Way', 'Minecraft', 'MC', '99999']
}
};
var list = function (friends) {
for (var key in object) {
console.log("Print Friends");
var friends1 = "bill";
console.log(friends1);
}
};

here's how the exercise wants me to write console.log

console.log("Printing a string");
var myString = "Awesome!";
console.log(myString);

and here's what I'm getting for problems

Oops, try again. Did you create a function called list?

here's the function

var list = function (friends) {
for (var key in object) {
console.log("Print Friends");
var friends1 = "bill";
console.log(friends1);
}
};


#9

Totally wrong!!! You just logged variable friends1.

for/in - loops through the properties of an object

In your case key is property of friends object:

key1 -> bill
key2 -> steve

So, all you need just use console.log to print out the keys.


#10

Please, look to examples and update your code.


#11

okay thanks for the input


#12

You can make a function like this:

function myFunction() {

}


#14

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