Oliver Eyton-Williams 36bad642c2 Add variable declaration (#34702)
* Declare variable

* Update guide/english/certifications/javascript-algorithms-and-data-structures/functional-programming/use-the-map-method-to-extract-data-from-an-array/index.md

Co-Authored-By: ojeytonwilliams <ojeytonwilliams@gmail.com>
2019-02-22 14:03:34 -08:00

1.2 KiB

title
title
Use the map Method to Extract Data from an Array

Use the map Method to Extract Data from an Array

:speech_balloon: Hint: 1

array.prototype.map takes a function as in input and returns an array. The returned array includes elements that is processed by the function. This function takes individual elements as input.

Spoiler Alert!

warning sign

Solution ahead!

:rotating_light: Intermediate Code Solution:

  const rating = watchList.map(item => ({title: item["Title"], rating: item["imdbRating"]}));

Code Explanation:

Using ES6 notation, each item in array is processed to extract title and rating. Parantheses are needed to return an object.