Functional Programming - Use the map Method to Extract Data from an Array

Three questions:

  1. Is the function seen here using “arrow function” syntax?
  2. can it be described as an anonymous function?
  3. Why is the object being returned in parenthesis?
item => ({title: item["Title"], rating: item["imdbRating"]})

Challenge: Functional Programming - Use the map Method to Extract Data from an Array

Link to the challenge:

  • yes
  • yes (if im not mistaken)
  • its “syntax” really, otherwise its not going to return that “object” for each of those “item”, to simply put if it was used with a “return” statement (as you would in a function) then you would not need that “parenthesis”

hope this was helpful, happy learning :slight_smile:

1 Like

I suggest you to take a look a the MDN Web Docs for a great and complete explanation on arrow functions: Arrow function expressions - JavaScript | MDN (mozilla.org)

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.