From 4fb1c32cbca114f2c515c340efdb49abaa0c4a86 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 17 Jan 2017 15:09:00 -0300 Subject: [PATCH] Max Red - beautified code by replacing a for for a map (: [skip ci] --- client/src/app-components/stats-chart.js | 1 - client/src/app-components/stats.js | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/client/src/app-components/stats-chart.js b/client/src/app-components/stats-chart.js index 5e4704b7..1ed7480e 100644 --- a/client/src/app-components/stats-chart.js +++ b/client/src/app-components/stats-chart.js @@ -93,7 +93,6 @@ class StatsChart extends React.Component { } }; } - } diff --git a/client/src/app-components/stats.js b/client/src/app-components/stats.js index 337bf446..a93e67dd 100644 --- a/client/src/app-components/stats.js +++ b/client/src/app-components/stats.js @@ -149,14 +149,14 @@ class Stats extends React.Component { let realPeriod = result.data.length / this.getStrokes().length; - for (let i = 0; i < result.data.length; i++) { - newStats[result.data[i].type] += result.data[i].value * 1; + result.data.map((item) => { + newStats[item.type] += item.value * 1; - newStrokes[ ID[result.data[i].type] ].values.push({ - date: result.data[i].date, - value: result.data[i].value * 1 + newStrokes[ ID[item.type] ].values.push({ + date: item.date, + value: item.value * 1 }); - } + }); this.setState({stats: newStats, strokes: newStrokes, period: realPeriod}); }