Stuck on Lesson: Use Filter to Extract Data from an Array

Link to Challenge](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/use-the-filter-method-to-extract-data-from-an-array)

My code so far:

//This rating code is good so far:

let rating = []

rating = watchList.map(movie => {
  let emptyObj = {}
  let {Title, imdbRating} = movie
  emptyObj['title'] = Title
  emptyObj['rating'] = imdbRating
  return emptyObj
  })
  

// highRating code is giving me an empty array. 

let highRating = []

highRating = rating.filter(
  over8 => parseFloat(over8['imdbRating']) >= 8.0
)




console.log(highRating)

I understand the code could be done more succinctly since I had a peek at the solution. But I want to fix the code that I was able to come up with myself.

I am able to meet the first half of the criteria set by the challenge. 1) I have not mutated the global variable watchList. 2) I am able to return a new array, rating, with a list of objects as its elements with just the movies’ Title and their imdbRating.

My highRating array, however, returns just an empty array. Here is my logic for my highRating code:
On my rating array, call the filter method. The filter method’s parameter, over8, takes in each element in the rating’s array which is an object as its argument. The filter method also contains a callback function in which I find the value of the imbdRating and convert it from a string to decimal number which I then perform a comparison operator. If it is greater than or equal to 8.0, it evaluates to true and the object is added to the new array highRating. The movie “Avatar” should not be added b/c its rating is 7.9.

Where did I make my mistake?

Thanks

@nwu4273 Remember, rating is an array of objects, but the property names are different than the ones in the objects in watchList. You changed them in the map callback function.

FYI - you do not need the following two initializations because map and filter both return an array.

let rating = [];

let highRating = [];

Instead you can initialize with the result of the watchList.map and rating.filter.

Yeah, I see what the issue is now. Thanks!