From: Jérôme Benoit Date: Thu, 1 Feb 2024 16:37:29 +0000 (+0100) Subject: refactor: cleanup control flow in statistic helpers X-Git-Tag: v1.2.34~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=736073f0c51fc24b3d676fa2cedc6052f928fbbc;p=e-mobility-charging-stations-simulator.git refactor: cleanup control flow in statistic helpers Signed-off-by: Jérôme Benoit --- diff --git a/src/utils/StatisticUtils.ts b/src/utils/StatisticUtils.ts index e4d6ca41..9ca4398c 100644 --- a/src/utils/StatisticUtils.ts +++ b/src/utils/StatisticUtils.ts @@ -74,9 +74,7 @@ export const stdDeviation = ( dataSet: number[], dataSetAverage: number = average(dataSet) ): number => { - if (Array.isArray(dataSet) && dataSet.length === 0) { - return 0 - } else if (Array.isArray(dataSet) && dataSet.length === 1) { + if (Array.isArray(dataSet) && (dataSet.length === 0 || dataSet.length === 1)) { return 0 } return Math.sqrt(