Question on filter() bits and pieces

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:

This is still destructuring in the function arguments.

Did you do the lesson on destructuring in the argument list? If you are having trouble, I recommend reviewing that lesson and asking questions about it.

This looks awfully like you copied an answer from somewhere and don’t understand what it is doing… I highly recommend going back and doing these exercises without copying. There aren’t answers to copy for the certification projects and you need to build up your ability to create answers without copying before you get to those projects.

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