Files
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

869 B

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

Use the map Method to Extract Data from an Array


Hints

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.


Solutions

Solution 1 (Click to Show/Hide)
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.