refactor: cleanup control flow in statistic helpers
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 1 Feb 2024 16:37:29 +0000 (17:37 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 1 Feb 2024 16:37:29 +0000 (17:37 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/utils/StatisticUtils.ts

index e4d6ca41835e574b1a322c1ef6c5816f213cdd5e..9ca4398ca76590250de3b1c5a935f42ca373cd6f 100644 (file)
@@ -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(