# Unable to pass "Use the filter Method to Extract Data from an Array"

**URL:** <https://group.classcentral.com/t/unable-to-pass-use-the-filter-method-to-extract-data-from-an-array/24426>\
**Category:** JavaScript Bootcamp\
**Created:** [February 15, 2022, 7:01am UTC](https://group.classcentral.com/t/unable-to-pass-use-the-filter-method-to-extract-data-from-an-array/24426 "2022-02-15T07:01:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacobra\_the\_Great](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/jacobra_the_great/32/3612_2.png) [@Jacobra\_the\_Great](https://group.classcentral.com/u/Jacobra_the_Great)\
**Post date:** [February 15, 2022, 7:01am UTC](https://group.classcentral.com/t/unable-to-pass-use-the-filter-method-to-extract-data-from-an-array/24426/1 "2022-02-15T07:01:04Z")

</div>

I can’t seem to pass this test, and I’m pretty sure it’s because the ratings numbers need to be converted back into strings. Does anybody know how to do that? The toString() method doesn’t seem to be working.

Here’s my code:

```auto
const filteredList = watchList.map(film => {
  return {
    title: film.Title,
    rating: parseFloat(film.imdbRating)
  }
}).filter(film => film.rating >= 8.0);

console.log(JSON.stringify(filteredList));

```

---

<div class="post-metadata">

**Author:** ![kulbirsaini](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/kulbirsaini/32/4608_2.png) [@kulbirsaini](https://group.classcentral.com/u/kulbirsaini)\
**Post date:** [February 15, 2022, 10:04am UTC](https://group.classcentral.com/t/unable-to-pass-use-the-filter-method-to-extract-data-from-an-array/24426/2 "2022-02-15T10:04:55Z")

</div>

Try to use . filter on filteredlist

---

<div class="post-metadata">

**Author:** ![rocio](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@rocio](https://group.classcentral.com/u/rocio)\
**Post date:** [February 15, 2022, 11:47am UTC](https://group.classcentral.com/t/unable-to-pass-use-the-filter-method-to-extract-data-from-an-array/24426/3 "2022-02-15T11:47:41Z")

</div>

Try filtering first and then doing the mapping. Don’t know if the order matters, but it worked for me that way.  
Also, do you need the `return` within map? Could that be affecting the code somehow? I honestly don’t know, but when mappin I just did it like this:

```auto
.map(movie => ({
   title: movie["Title"],
   rating: movie["imdbRating"]
 })

```

I suggest doing just either the map or the filter first and console.log that to see if things are going as you expected.

I hope that helps!

---

<div class="post-metadata">

**Author:** ![Jacobra\_the\_Great](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/jacobra_the_great/32/3612_2.png) [@Jacobra\_the\_Great](https://group.classcentral.com/u/Jacobra_the_Great)\
**Post date:** [February 15, 2022, 5:45pm UTC](https://group.classcentral.com/t/unable-to-pass-use-the-filter-method-to-extract-data-from-an-array/24426/4 "2022-02-15T17:45:15Z")

</div>

Thanks! Yes, I think you’re right. From the research I’ve done it looks like filtering first, then returning the filtered array as a new array with map is probably going to work.

I’ll give it a try and let you know if it worked.

---

<div class="post-metadata">

**Author:** ![Jacobra\_the\_Great](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/jacobra_the_great/32/3612_2.png) [@Jacobra\_the\_Great](https://group.classcentral.com/u/Jacobra_the_Great)\
**Post date:** [February 15, 2022, 5:54pm UTC](https://group.classcentral.com/t/unable-to-pass-use-the-filter-method-to-extract-data-from-an-array/24426/5 "2022-02-15T17:54:22Z")

</div>

Okay, check this out. I did a Google search and found something called the unary plus operator, which forces JavaScript to treat a string like a number. The cool thing about it is it doesn’t change the string to a number, but instead ignores the string state in order to perform mathematical operations. Here’s my new, updated, working beautifully, code:

```auto
const filteredList = watchList.map(film => {
  return {
    title: film.Title,
    rating: film.imdbRating
  }
}).filter(film => +film.rating >= 8.0);

console.log(filteredList);

```

Sweet!
