Tell us what’s happening:
This may seem like a silly question, but I just want to be sure I’ve understood all the working parts in this.
Title: title
are a key value pair, right?
When I was using map(), I wanted to see what would happen if I used Title: title, imdbRating: rating
to the right of the arrow function (to see if that changed things). It did. Nothing appeared in the console. When I changed the elements back to title, rating
in the map() method, the correct results appeared in the console again.
My question is why. I’ve noticed this before in other exercises. If I keep some elements in the code (i.e. keeping the ‘Key’ when all I need is the ‘Value’), the code does not function correctly. Does keeping certain code ‘in’ block other code from functioning? Is this because of a parent-child relation or something different?
Thanks as always!
Nick
Your code so far
const filteredList = watchList.map(({Title:title, imdbRating:rating})=>({title, rating})).filter(film=>{return parseFloat(film.rating)>= 8.0});
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36
Challenge: Use the filter Method to Extract Data from an Array
Link to the challenge: