Sunday 26 March 2017

Printing all properties in a Javascript Object

I am following a code academy tutorial and i am finding this difficult.



The assignment is the following:




Use a for-in loop to print out all the properties of nyc.




var nyc = {
fullName: "New York City",

mayor: "Michael Bloomberg",
population: 8000000,
boroughs: 5
};

// write your for-in loop here
for (var in nyc){
console.log(population);
}

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...