0

I am getting an eslint warning for unexpected use of comma. I found this answer but it does not match my issue.

This is my code:

const reduced = _.map(_.keys(grouped), function(e) {
    return _.reduce(grouped[e], function(r, o) {
        return r.count += +o.amount, r
    }, {price: parseFloat(e), count: 0, amount: e.amount})
})

How do I get rid of the warning? Thank you very much.

user3808307
  • 2,270
  • 9
  • 45
  • 99

1 Answers1

3

Your return statement in the .reduce callback can be written as

  r.count += +o.amount;
  return r;

That does exactly the same thing, but it should make ESLint happy.

Pointy
  • 405,095
  • 59
  • 585
  • 614