Writing the setDetails Function
You have been working with methods and have seen that they can be invoked to cause a block of code to run. Functions and methods are really just a list of steps that you would like to use again and again. Calling a function is like saying “Make a sandwich” instead of “Lay out two slices of bread. Put prosciutto, salami, and provolone on one slice. Put the other slice of bread on top.”
You will write seven functions for Ottergram in this chapter. Your first function will do two things: change the detail image and the detail image title. Add this function declaration to main.js.
var DETAIL_IMAGE_SELECTOR = '[data-image-role="target"]'; var DETAIL_TITLE_SELECTOR = '[data-image-role="title"]'; var THUMBNAIL_LINK_SELECTOR ...
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.