Tell us what’s happening:

Your code so far


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

Link to the challenge:

We can’t see your code.

Please write it in the forum.

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.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

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.

I still can’t see your code.

Have you tried the problem yet?

const filteredList = "title";

const users = [

  { title: 'rating', imbRating: 8.3 },

  { title: 'rating', imbRating: 8.6 },

  { title: 'rating', imbRating: 8.8 }


const usersUnder30 = users.filter(user => user.age < 9.0);


You appear to have substantially changed the code for this challenge. I would reset the code and not modify the watchList object at all.

please eloborate youre telling me not to answer the code question and just click runtest?

No. I’m telling you not to delete the huge amount of code that is already there when you start the challenge.

ok thank you i appreciate your help

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.

  1. 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.

  2. filter the array returned from map using the condition >= 8 for the rating property.

Example using the challenge example code
const users = [
  { name: 'John', age: 34 },
  { name: 'Amy', age: 20 },
  { name: 'camperCat', age: 10 },

const onlyAge = => ({ userAge: userObject.age }));
console.log(onlyAge); // [ { userAge: 34 }, { userAge: 20 }, { userAge: 10 } ]

const ageUnder30 = onlyAge.filter((ageObject) => ageObject.userAge < 30);
console.log(ageUnder30); // [ { userAge: 20 }, { userAge: 10 } ]
1 Like

thank you I realized my mistake

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