Function syntax


sorry for the long post but i think it'll be a quick fix if yall can help.

here's the code:

var friends = {
bill: {
firstName: "Bill",
lastName: "Jones",
number: 000-000-0001,
address: ['123 Main St.', 'Small Town', 'TX', '12345']
steve: {
firstName: "Steve",
lastName: "Smith",
number: 000-000-0002,
address: ['125 Main St.', 'Small Town', 'TX', '12345']
var list = function (phonebook)
for (true) {

here's the error:

SyntaxError: Unexpected token )

and it's talking about the syntax of the function.

here's the instructions:

-Create a function list that takes a single parameter.
-In the body of the function, write a for/in loop.
-In the loop, use console.log to print out the key. (For example, if you only have bill and steve as entries, list should just print out "bill" and "steve".)



The problem is with the syntax of the loop inside the list function here:

for(true) is not valid syntax. You can read about for/in loop here. See the examples.

Also you can't use friends variable inside the function list because is undefined in this scope. You can use the parameter of the function - phonebook.


I appreciate all that but I still cant figure out what to do, how to fix it/what to use


Change your for loop to if.


even though the instructions say to use a for/in loop?


Here is example how to use for/in loop to list the properties of object:

var obj = {a:1, b:2, c:3};
for (var prop in obj) {

Try to think how to use it in your function to list the properties of friends.


That helped! Thank you so much!