From 57d97867f448652af1b241a585dd930ca4424a6a Mon Sep 17 00:00:00 2001 From: igotis Date: Wed, 10 Mar 2021 21:44:48 +0200 Subject: [PATCH] feat: add function min, max. avg --- src/index.js | 58 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index d54b3622..2c7a7283 100644 --- a/src/index.js +++ b/src/index.js @@ -1,12 +1,64 @@ exports.min = function min (array) { - return 0; + + if (Array.isArray(array) && array.length) { + // array exists and is not empty + var min = array[0]; + + for (i=0; imax) max = array[i]; + + } + return max; + } else { + return 0; + } + } exports.avg = function avg (array) { - return 0; + + if (Array.isArray(array) && array.length) { + let l = (array.length); + + let summ = 0; + + + + for (i=0; i