10. List ALL the properties!


#1

Hi,

https://www.codecademy.com/courses/objects-ii/1/5?curriculum_id=506324b3a7dffd00020bf661#

I don't really understand this. When I run this code it says:"SyntaxError: missing before statement."

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
for (var x in nyc) 
console.log{(nyc[x]);
}

#2

for (var x in nyc) 
console.log{(nyc[x]);
}

syntax error want say to you, that your code is not fix, some things is missing or your code not in my formats. such as forget semicolon ; or have no closed block } or something else.
is this part of your code you have many problem.

your open block is in wrong place, is after console.log. this should be open after for()...

the correct is:

for (var x in nyc) {
    console.log(nyc[x]);
}

#3

I was wondering that how the code knows that x means a value. Because x is in square brackets inside nyc, is it that what/which marks that x means value?


#4

x come from here:

for (var x in nyc)

but this is a magic never ask how it work :wink:
you just speak with this language, the process how he understand what you want, is in his mind.
you are a programmer or web designer with some language, not a developers of that.

i want to give me this "|-|3|_|_0 /\/\4|/14)", may you don't know what is this, but i now how work with this text.
|-| -> H
3 -> e
|_ -> L
0 -> O
/\/\ -> M
4 -> A
|/ -> r
1 -> i
means of this is> Hello Maria :wink:


#5

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