diff --git a/components/percentage.jsx b/components/percentage.jsx index 038e957..d2aa94d 100644 --- a/components/percentage.jsx +++ b/components/percentage.jsx @@ -1,24 +1,20 @@ export default ({ activity }) => { - const leftActivity = activity - .filter(a => a.ch === "l") - .map(a => a.endTime - a.startTime) - .reduce((a, c) => a + c, 0); - const rightActivity = activity - .filter(a => a.ch === "r") - .map(a => a.endTime - a.startTime) - .reduce((a, c) => a + c, 0); + const leftActivity = activity.filter(a => a.ch === "l"), + rightActivity = activity.filter(a => a.ch === "r"); + const [l, r] = [leftActivity, rightActivity].map(activity => { + return activity + .map(a => a.endTime - a.startTime) + .reduce((a, c) => a + c, 0); + }); + const sum = l + r; return (