From f60371fd957c7109ca9cb700839d79fa65dd155f Mon Sep 17 00:00:00 2001 From: Julian Holfeld Date: Sun, 21 Jan 2024 12:21:45 +0100 Subject: [PATCH] refactor: workedSeconds reduce --- Sources/com.morphclue.wakatime.sdPlugin/main.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Sources/com.morphclue.wakatime.sdPlugin/main.js b/Sources/com.morphclue.wakatime.sdPlugin/main.js index 2b784cf..86af8de 100644 --- a/Sources/com.morphclue.wakatime.sdPlugin/main.js +++ b/Sources/com.morphclue.wakatime.sdPlugin/main.js @@ -123,11 +123,7 @@ function setTitle(title) { } function calculateRemainingMinutes(durations, minutesToReach) { - let workedSeconds = 0; - for (const value of durations) { - workedSeconds += value.duration; - } - + const workedSeconds = durations.reduce((total, value) => total + value.duration, 0); const remainingTime = minutesToReach - Math.floor(workedSeconds / 60); return remainingTime > 0 ? remainingTime : 0; }