Returning Values from Functions

You have completed the first (or, rather, last) item on the plan and picked up some JavaScript know-how along the way. Now you will move on to the next two items on the list: getting the image and the title from a thumbnail. For each of these, you will write a new function.

Add a function declaration in main.js for imageFromThumb. It will accept a single parameter, thumbnail, which is a reference to a thumbnail anchor element. It will retrieve and return the value of the data-image-url attribute.

function setDetails(imageUrl, titleText) {

function imageFromThumb(thumbnail) {
  'use strict';
  return thumbnail.getAttribute('data-image-url');

The getAttribute method does the opposite of the ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.