Exercise Set 13

Exercise 6 of 6

Show the city of the house when the button is clicked.


<button id="showCityButton">Show city</button>
<p id="cityParagraph"></p>


var showCityButton = document.getElementById("showCityButton");
var cityParagraph = document.getElementById("cityParagraph");

var house = {
    numBedrooms: 4,
    numBathrooms: 3,
    squareFeet: 2000,
    address: {
        street: "123 Main St",
        city: "Sacramento",
        state: "CA"

showCityButton.addEventListener("click", showCity);

function showCity() {
    // your code will appear here

You must be signed in to type your code.

Show your answers to the instructor before moving on.

Last exercise Next topic First exercise