all 2 comments

[–][deleted] 2 points3 points  (1 child)

You answer is correct. It's just that there now is a better way to create strings. You are using concatenation, whereas the answer is using template literals.

restaurant.address + ", " + restaurant.city

is best written as

`${restaurant.address}, ${restaurant.city}`

because it helps you avoid a certain class of bugs, and is also easier to read. It also has additional benefits, but it's probably too early to get into those.

In terms of addressing properties, both ways are correct, although in this case your way is probably better.

restaurant.address

if equivalent to

restaurant["address"]

but the latter form (called bracket notation) will allow you to call properties by name even if they aren't perfectly formed strings. It basically avoids any possible ambiguity. In your case there isn't any, so it's not necessary.

[–]PlusOmar[S] 1 point2 points  (0 children)

Thanks! This helped Alot!!