Iterating Through the Array of Thumbnails

Connecting the thumbnails to your event handling code will be short and sweet. You will write a function that will be the starting point for all of Ottergram’s logic. Other programming languages have a built-in mechanism for starting an application, which JavaScript lacks. But not to worry – it is easy enough to implement by hand.

Begin by adding an initializeEvents function at the end of main.js. This method will tie together all of the steps for making Ottergram interactive. First, it will get the array of thumbnails. Then, it will iterate over the array, adding the click handler to each one. After you have written the function, you will add a call to initializeEvents at the very end of

Get Front-End Web Development: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.