Introduction to Objects II -No. 10: List ALL the Properties!



I do not understand why I am correct.
Can someone translate the For-In loop in "English speaking language"?

var nyc = {
fullName: "New York City",
mayor: "Bill de Blasio",
population: 8000000,
boroughs: 5

// write a for-in loop to print the value of nyc's properties
var x = "fullName";

for (x in nyc) {

From what I understand the For-In loop states that:
"For every fullName in object nyc, I will print out fullName.value"


Hello! Let me try and explain the for / in loop for you.

Let's say we have a list of employees:


And we want to do something for each and every single one of the employees in the list.
Then we will say for an_employee in the_employee list, here an_employee is the name of the employee in the list.

for employee in employee_list {
    console.log("Hi, I'm " + employee);

Now we can execute some code for each employee.


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