From d35cab0a67cf10cac72ca3d0b5e6233c904910a1 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Mon, 16 Jul 2018 20:10:57 +0200 Subject: [PATCH] Refactor code, courtesy of @galfert --- app/components/chart-contributions-by-type/component.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/components/chart-contributions-by-type/component.js b/app/components/chart-contributions-by-type/component.js index ea3eed0..f7f34dc 100644 --- a/app/components/chart-contributions-by-type/component.js +++ b/app/components/chart-contributions-by-type/component.js @@ -18,11 +18,7 @@ export default Component.extend({ .map(c => { return { kind: c.kind, amount: c.amount } }).reduce(function (kinds, c) { - if (c.kind in kinds) { - kinds[c.kind] = kinds[c.kind] + c.amount - } else { - kinds[c.kind] = c.amount; - } + kinds[c.kind] = (kinds[c.kind] || 0) + c.amount; return kinds; }, {});