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

Tell us what’s happening:

Not sure where I’m going wrong. It seems like it should work. When I console.log I get the title and the rating. The only difference between my result and the answer is the quotation marks. My result has single quotes around the actual title and actual rating. The challenge answer has double quotes around each item. I’m not sure if this is the issue or how to fix it. I was initially using dot notation but switched to bracket notation to try to capture the double quotes. That didn’t help.

Your code so far

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

const ratingList = watchList.filter(movie => movie.imdbRating > 8);

const list = ratingList.map(movie =>{
  let filteredList ={};
  filteredList["title"] = movie["Title"];
  filteredList["rating"] = movie["imdbRating"];
  return filteredList;
  });

console.log(list)

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

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

Link to the challenge:

Notice the console.log at the bottom:

console.log(filteredList);

I agree this could be made a little clearer, but you need to put your final list in a variable named filteredList.

1 Like

Thank you. I appreciate it.