refactor: cleanup statistic helpers code
[e-mobility-charging-stations-simulator.git] / src / utils / Utils.ts
index 4f89179f1dc5f45ba3b954ff38f1b0ceafe207c5..be372de697f43b384a6929a14884567fa23b72d0 100644 (file)
@@ -343,8 +343,11 @@ export class Utils {
     if (Array.isArray(dataSet) === true && dataSet.length === 1) {
       return dataSet[0];
     }
-    dataSet = dataSet.slice().sort((a, b) => a - b);
-    return (dataSet[(dataSet.length - 1) >> 1] + dataSet[dataSet.length >> 1]) / 2;
+    const sortedDataSet = dataSet.slice().sort((a, b) => a - b);
+    return (
+      (sortedDataSet[(sortedDataSet.length - 1) >> 1] + sortedDataSet[sortedDataSet.length >> 1]) /
+      2
+    );
   }
 
   // TODO: use order statistics tree https://en.wikipedia.org/wiki/Order_statistic_tree