6. List them all Contact list


#1

https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/6?curriculum_id=506324b3a7dffd00020bf661#

Hi, so I think I'm just really confused on what this is asking for.
My error message has been: Oops, try again. It looks like your list function isn't printing the right output.
When I run this code I get the information for Steve. These are the instructions. Any help would be so appreciated. I've read other forums about it but I just don't understand! TYSM

  1. Create a function list that takes a single parameter.
  2. In the body of the function, write a for/in loop.
  3. 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".)


var friends = new Object();

friends.bill = {
    firstName: "Bill",
    lastName: "Gates",
    number: "(410) 422-5778",
    address: ['17439 Delaware Dr', 'Newark', 'DE', '19971']
    };
friends.steve = {
    firstName: "Steve",
    lastName: "Mens",
    number: "(410) 410-4223",
    address: ['37 Boston St', 'NorthFront', 'DE', '19718']
    };
    
    var list = function(friends) {
    for (var steve in friends); {
    console.log(steve) 
    }
    };


#2

Nevermind, I realized it was because of a misplaced semi colon. This seems to happen to me often, if someone would like to explain the use of semi colons I'd really appreciate that too! Thanks!


#3

This article here explains the use of Semi colons indepth:

Use of semicolons in JS

In a nutshell, they are used to denote an end of line.


#4

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