Combination of Filter and Array using ES6

Tell us what’s happening:
Mind helping me figuring out why the code below doesn’t work?
Your code so far

// Only change code below this line

var filteredList = watchList
.map(({Title:title, ImdbRating:rating}) => ({title, rating}))
.filter(ref => ref.rating>=8.0);


// Only change code above this line

console.log(filteredList);

The code above returns and empty array. [ ]

code below works.

code below works.
var reference = watchList
.map(ref => ({
  title: ref.Title,
  rating: ref.imdbRating
}))

var filteredList = reference.filter(ref => ref.rating >= 8.0
)

Code below works too.

var filteredList = watchList
.map(ref =>{
  return{
    title: ref.Title,
    rating: ref.imdbRating
  }
})
.filter(ref => ref.rating>=8.0)

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.


Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below, 
because they allow your code to properly format in the post.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 OPR/71.0.3770.228.

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

Link to the challenge:

doing just this, the value of filteredList is:

[ { title: 'Inception', rating: undefined },
  { title: 'Interstellar', rating: undefined },
  { title: 'The Dark Knight', rating: undefined },
  { title: 'Batman Begins', rating: undefined },
  { title: 'Avatar', rating: undefined } ]

check really carefully for spelling errors

1 Like

I see…
Thanks for the help!
let me go back to my corner and be ashamed of myself
:sweat_smile:

well, you fixed it!

Happy coding!

image

1 Like