From f4bc5f523a174b8d45d65f9b7294a50d8d11012e Mon Sep 17 00:00:00 2001
From: Pithon Kabiro <pithon.kabiro@hft-stuttgart.de>
Date: Fri, 24 Sep 2021 13:50:04 +0200
Subject: [PATCH] New functions: calculate monthly min/max values

Calculate the minimum and maximum of observation values for a monthly
interval
---
 public/js/src_modules/aggregate.mjs | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/public/js/src_modules/aggregate.mjs b/public/js/src_modules/aggregate.mjs
index 97c2c07..b38603f 100644
--- a/public/js/src_modules/aggregate.mjs
+++ b/public/js/src_modules/aggregate.mjs
@@ -55,6 +55,28 @@ const calculateAverageOfObservationValuesWithinDatesInterval = function (
   );
 };
 
+/**
+ * Calculate the minimum of observation values that fall within a time interval delimited by the first day and last day of a calendar month
+ * @param {Array} obsValuesForMonthIntervalArr An array of observation values that fall within one calendar month
+ * @returns {Number} A floating-point number representing the minimum of observation values within one calendar month
+ */
+const calculateMinimumObservationValuesWithinMonthInterval = function (
+  obsValuesForMonthIntervalArr
+) {
+  return Math.min(...obsValuesForMonthIntervalArr);
+};
+
+/**
+ * Calculate the maximum of observation values that fall within a time interval delimited by the first day and last day of a calendar month
+ * @param {Array} obsValuesForMonthIntervalArr An array of observation values that fall within one calendar month
+ * @returns {Number} A floating-point number representing the maximum of observation values within one calendar month
+ */
+const calculateMaximumObservationValuesWithinMonthInterval = function (
+  obsValuesForMonthIntervalArr
+) {
+  return Math.max(...obsValuesForMonthIntervalArr);
+};
+
 /**
  * Calculate the sum of observation values that fall within a time interval delimited by the first day and last day of a calendar month
  * @param {Array} obsValuesForMonthIntervalArr An array of observation values that fall within one calendar month
-- 
GitLab