This code is structured in six functions
buildDropDown()
This function populates the data in the dropdown menu that allows the user to select a city that
can be used to filter
and display the data for the events in that city. It first gets the dropdown menu element from
the HTML page and clears
its contents. Then it calls the getEventData function to retrieve the current list of events. It
uses the map() method
to create an array of just the city names from the events and uses the set object to get one the
distinct city names.
displayStats()
This function calculates and displays statistics for the events, including the total attendance,
average attendance,
minimum attendance, and maximum attendance. It calls the calculateStats() function to calculate
these statistics
from the given events array and updates the text content of corresponding HTML elements.
displayEventsData()
This function displays event data in a table on the HTML page. It first gets the table body
element and clears its contents.
Then, it loops through each event in the given events array and creates a table row for each
event,
populating it with the appropriate event data. Finally, it appends the row to the table body.
getEventData()
This function retrieves event data from local storage or the hard-coded events array if there is
no data in storage.
The localStorage object is used to store and retrieve data in the browser's local storage.