How to combine countBy and filter in lodash

I have following data array:

const data = [
  { year: 1900, title: 'test 1' },
  { year: 2000, title: 'test 2' },
  { year: 2000, title: 'test 3' },
  { year: 2000, title: 'test 4' },

My aim is to get an array of years where each given year appear more than twice:


the countBy is fairly easy to achieve by:


which returns the following object:

{'1900': 1, '2000': 3}

I’m stumbling upon the filtering part. I tried the following but it returns me an empty array:

  .filter((o) => {
    o > 2;

What would be the correct way?

165 thoughts on “How to combine countBy and filter in lodash”

  1. My programmer is trying to convince me to move to .net
    from PHP. I have always disliked the idea because of the expenses.
    But he’s tryiong none the less. I’ve been using WordPress on several websites for about a year and am concerned about switching to another
    platform. I have heard good things about
    Is there a way I can import all my wordpress content into it?
    Any kind of help would be really appreciated!

  2. Simply want to say your article is as surprising. The clearness in your publish
    is simply nice and i could think you are an expert in this subject.
    Fine along with your permission allow me to snatch your feed to stay up to date with drawing close post.
    Thank you 1,000,000 and please keep up the gratifying work.

  3. This design is wicked! You obviously know how
    to keep a reader amused. Between your wit and your videos,
    I was almost moved to start my own blog (well, almost…HaHa!) Fantastic job.
    I really enjoyed what you had to say, and more than that, how you presented it.
    Too cool!

  4. I think what you said made a lot of sense. But, what about
    this? suppose you added a little information? I ain’t suggesting your information is
    not solid., however suppose you added something to maybe get folk’s attention? I mean How to combine countBy and filter in lodash – JavaScript Help is kinda
    boring. You ought to glance at Yahoo’s front
    page and note how they create news headlines to get viewers interested.

    You might add a related video or a picture or two to grab people interested about everything’ve got to say.
    Just my opinion, it would bring your posts a little livelier.

  5. Wonderful items from you, man. I have consider
    your stuff previous to and you are just too great. I actually like what you’ve obtained here, certainly like what you are stating
    and the way in which during which you are saying it.

    You’re making it enjoyable and you continue to care for to stay it smart.
    I can’t wait to learn far more from you. That is actually
    a tremendous site.

  6. Very nice post. I just stumbled upon your weblog and wanted
    to mention that I have really loved surfing around your weblog posts.
    In any case I’ll be subscribing in your rss feed
    and I hope you write once more soon!

  7. I’m impressed, I have to admit. Rarely do I encounter a
    blog that’s both equally educative and entertaining,
    and let me tell you, you have hit the nail on the head.

    The problem is an issue that too few men and women are speaking intelligently
    about. I’m very happy I stumbled across this during my hunt for something concerning this.

  8. I’m curious to find out what blog system you are utilizing?
    I’m having some minor security problems with my latest site and I would
    like to find something more secure. Do you have any

  9. Excellent goods from you, man. I have understand your stuff previous to and you are just too
    excellent. I actually like what you’ve acquired here, really
    like what you’re saying and the way in which you say it.
    You make it enjoyable and you still care for to keep it wise.
    I can not wait to read much more from you. This is really a great website.

  10. Howdy, I do think your website may be having internet browser compatibility problems.

    Whenever I look at your web site in Safari, it looks fine
    however, when opening in Internet Explorer, it has some overlapping issues.
    I simply wanted to provide you with a quick heads up! Aside from
    that, excellent blog!

    Review my web site – special

  11. I was recommended this web site by my cousin. I’m not sure whether this post is written by him as nobody
    else know such detailed about my difficulty.
    You are wonderful! Thanks!

  12. hey there and thank you for your information – I’ve certainly picked up anything
    new from right here. I did however expertise a few technical issues using this
    web site, as I experienced to reload the web site lots
    of times previous to I could get it to load properly. I had been wondering if
    your web hosting is OK? Not that I am complaining, but sluggish loading instances times will
    often affect your placement in google and could damage your high quality
    score if ads and marketing with Adwords. Well I am adding this RSS to my email and can look out for much more of your respective interesting content.

    Ensure that you update this again very soon.


Leave a Comment