/* STEP 1: Given a movie object, copy its title into a new field called * textContent and return the movie. * * @param {object} movie A movie object from the JSON data set */ function setTitleContent(movie) { movie.textContent = movie.title; return movie; } /* STEP 2: Given a movie object, append the remaining fields into the * textContent field. Each function should append only the relevant field. * Chaining them together would create a textContent string such as the * following: * Mad Max: Fury Road (2015) - 120 minutes [8.1] * Make sure to include the correct spacing and punctuation marks. * * @param {object} movie A movie object from the JSON data set with the * title already copied into the movie.textContent field. */ function appendYear(movie) { movie.textContent = movie.textContent.concat(` (${movie.year})`); return movie; } function appendRuntime(movie) { movie.textContent = movie.textContent.concat(` - ${movie.runtime} minutes`); return movie; } function appendRating(movie) { movie.textContent = movie.textContent.concat(` [${movie.rating}]`); return movie; } /* STEP 3: Return a closure (arrow function) that takes a movie argument * and compares its .rating field with this function's rating argument. * Return true if the movie's rating satisfies this minimum criterion. * Note that you need to call parseFloat on the movie.rating field because * JSON data defaults to a string type. * * @param {number} rating The minimum movie rating that will cause the * closure to return true for a movie. */ function setMinRating(rating) { // If the minimum rating value passed in the query string is NaN, // the closure should always evaluate to false. // Whether or not this is desireable is up to the designer const minRating = Number.parseFloat(rating); return (movie) => Number.parseFloat(movie.rating) >= minRating; } /* STEP 3: Complete the following functions just as you did setMinRating. * You'll need to use parseInt instead of parseFloat, because these are * all integer values. */ function setMinYear(year) { const minYear = Number.parseFloat(year); return (movie) => Number.parseFloat(movie.year) >= minYear; } function setMaxYear(year) { const maxYear = Number.parseFloat(year); return (movie) => Number.parseFloat(movie.year) <= maxYear; } function setMinTime(mins) { const minMins = Number.parseFloat(mins); return (movie) => Number.parseFloat(movie.runtime) >= minMins; } function setMaxTime(mins) { const maxMins = Number.parseFloat(mins); return (movie) => Number.parseFloat(movie.runtime) <= maxMins; } /* buildItem - Helper function that creates a DOM
  • element, adds the * list-group-item class, and inserts the movie's text content. Do not * modify. * * @param {object} movie The movie object to create as a list item * @param {object} list The