diff --git a/src/index.js b/src/index.js index d54b3622..85b17b34 100644 --- a/src/index.js +++ b/src/index.js @@ -1,12 +1,25 @@ - -exports.min = function min (array) { - return 0; +exports.min = function min(arr) { + if (!arr || arr.length == 0) { + return 0; + } + return Math.min(...arr); } -exports.max = function max (array) { - return 0; + +exports.max = function max(arr) { + if (!arr || arr.length == 0) { + return 0; + } + return Math.max(...arr); } -exports.avg = function avg (array) { - return 0; +exports.avg = function avg(arr) { + if (!arr || arr.length == 0) { + return 0; + } + let sum = 0; + for (let i = 0; i < arr.length; i++) { + sum += Number(arr[i]); + } + return sum / arr.length; }