5.14 Exercise: The Address Object
Here is your first exercise for this section. I want you to create an address object with three properties, street, city and zip code. When you do that, create a function called showAddress that takes an address object and displays all the properties of that object with their values. So pause the video and when you're done, come back and continue watching the fix. So now I'm going to create an address object, we can use the let or const keyword, in this case it doesn't really matter, here we're using the object literal syntax to initialize this object, so we have the street property which we set to a certain value, it doesn't really matter then is the city property , and finally postcode. Then we need to create this function, showAddress, which takes an address object, and here to list the properties of this object, we're going to use the for in loop. So let's leave the key address and then we do a console. Log of key and address of key, so here we use the bracketed notation for the value of a given key. And finally, we call this function, showAddress and pass our address object Save the changes and here is the result. That's it for this little exercise on the address object in JavaScript, let's get together for a very next video.