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/96.0.4664.110 Safari/537.36
Challenge: Use the filter Method to Extract Data from an Array
When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
Use the filter Method to Extract Data from an Array
Another useful array function is Array.prototype.filter() , or simply filter() .
filter calls a function on each element of an array and returns a new array containing only the elements for which that function returns true . In other words, it filters the array, based on the function passed to it. Like map , it does this without needing to modify the original array.
The callback function accepts three arguments. The first argument is the current element being processed. The second is the index of that element and the third is the array upon which the filter method was called.
See below for an example using the filter method on the users array to return a new array containing only the users under the age of 30. For simplicity, the example only uses the first argument of the callback.
You are supposed to loop the watchList array. Also, neither it nor the array you created contains objects with the properties you are accessing (there is no age property on the objects). You seem to have taken parts of the example code which isn’t going to work.
map the watchList array, inside the map callback return an object with the keys title and rating set to the values of the Title and imdbRating properties.
filter the array returned from map using the condition >= 8 for the rating property.