Question regarding map and filter function

Hi all campers,

So I have a question regarding this challenge.

I am still confused about how this type of function works so I try to manipulate every argument in the function and try to figure it out by myself.

So the answer I have is what is shown on the answer page

var filteredList = => {
  return {
    title: watchList.Title,
    rating: watchList.imdbRating
.filter(watchList => {
  return parseFloat(watchList.rating) >= 8.0;

I assume that within title: watchList.Title and rating: watchList.imdbRating, both title and rating are arbitary variables that I can created by myslef (though I know that in order to pass this challenge I need to set it to title and rating), however, for title I can change it to anything such as name, but once I change rating, the function won’t work normally, instead, it returns my an empty array [].

This one has got me for over 30 min, thanks in advance!

Hi you are correct in that both title and rating are variable names set by yourself. The reason title seems to be able to be changed while rating cannot, is because you use rating in the .filter() method.

Consequently, if you change the name of rating to something else, the .filter() method looks for a rating property in watchList and finds nothing, hence empty array.

OMG I didn’t notice that. Thank you so much lol I got it. :rofl:

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