Functional Programming - Use the filter Method to Extract Data from an Array

Tell us what’s happening:
Month 8 of Javascript and Functional Programming is kicking my butt.

Your code so far
this is not my code… I’m just trying to understand this example that passes the test, as nothing I write passes.

filter is returning the correct output even though no parseFloat is being used to turn 8.0 rom a string to an interger… that’s the first question.
const filteredList = watchList
.filter(movie => movie.imdbRating >= 8.0)
.map(movie => ({ title: movie[“Title”], rating: movie[“imdbRating”] }));


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.

  .filter(movie => movie.imdbRating >= 8.0)
  .map(movie => ({ title: movie["Title"], rating: movie["imdbRating"] }));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Functional Programming - Use the filter Method to Extract Data from an Array

Link to the challenge:

2nd question is to please explain the map line and the first parenthesis before the object curly bracket … not a syntax I’ve seen before.

Thank You for any help!

It’s better if you try your own code and if it doesn’t pass then you can paste it in here and we can help you figure it out.

When you want to return an object from a single line arrow function then you have to wrap it in parens because otherwise the curly braces for the object would be seen as denoting a function body instead of an object.

1 Like

Thank You for the detailed explanation of the 2nd question! I understand now!

been another week long test for me…

coerced ???


not following, sorry…

not sure what you are trying to say…

Thanks for trying Randell.

Thank You Randell;

Not following at all…

I’ll try somewhere else, Thank You.

This sort of confusion about what happens isn’t exactly uncommon when you find an answer and copy-paste it.

I highly, highly, highly recommend you show us code you tried and understand. Its much easier for us to try to help you build to a correct answer from what you understand instead of helping you decipher an answer you found.

1 Like

sorry Jeremy , doing the best I can…

I’ve only asked 2 questions in 8 months.

I always thought 10 was greater than 8

as you know I start studying at 6a.m. … it’s break time…

It is. The number 10 is greater than the number 8.

In JS, the string 10 is less than the string 8 because comparing strings does not work the way we think it should when those strings represent numbers. You can easily test this in your browser’s console. Try typing:

"10" > "8"

Heck, only 2 questions in 8 months probably means you aren’t asking enough questions.

1 Like

and I understand this concept… I think that’s what is making the 10 > 8 example is so confusing. Yes, they are strings and are evaluated differently. And the test says I MAY have change the strings to numbers. But “It still works because there are no ratings like "10.0" that would not get filtered.” is a double negative my brain can’t compute…

You are right Jeremy… but the site seems to want you to use exhaust every tool before asking any questions…

my brain has always learned different than others…

I’m an award winning carpenter and artist…

teaching me MAY be more challenging than Javascript.

Thank You very much for trying!!!

You all have my respect for knowing your trade!

Where does it say that? You should ask questions before reading other people’s answers!!

If I press Help it says" If you’ve already tried the Read-Search-Ask method, then you can ask for help on the freeCodeCamp forum."
Before making a new post please see if your question has already been answered on the forum.

So I was reluctant for 8 month, lol …

I watched a tutorial and saw that I left out my If statement …

Yea, you should use Read-Search-Ask, and part of that reading/searching is making sure you have read around on the forum. But ASK is a very important part of Read-Search-Ask.

1 Like

The only reason I’m asking is because of your awesome support and encouragement ,Sir…
I will continue to grind it out and ask you questions when I get stuck.

The last time I learned to code it was on a TRS-80 in BASIC in 1984. : D

I followed you on GIT HUB.

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