diff --git a/index.js b/index.js index 9e3b3ff..39af778 100644 --- a/index.js +++ b/index.js @@ -48,10 +48,6 @@ let mode = numbers => { }; let standardDeviation = numbers => { - if (!Array.isArray(numbers)) { - return null; - } - return Math.sqrt(variance(numbers)); }; diff --git a/test/test.js b/test/test.js index 29bbe1c..8776bb7 100644 --- a/test/test.js +++ b/test/test.js @@ -7,13 +7,33 @@ var stats = require('../index'); describe('#stats', function() { it('Median', function() { - var result = stats.median([1,2,3]); + var result = stats.median([1, 2, 3]); expect(result).to.equal(2); }); - it('Not an array error', function() { + it('Median with even length array', function() { + var result = stats.median([1, 2, 3, 4]); + expect(result).to.equal(2.5); + }); + it('Not an array error median', function() { var result = stats.median(1); expect(result).to.equal(null); }); + it('Not an array error mean', function() { + var result = stats.mean(1); + expect(result).to.equal(null); + }); + it('Not an array error mode', function() { + var result = stats.mode(1); + expect(result).to.equal(null); + }); + it('Not an array error variance', function() { + var result = stats.variance(1); + expect(result).to.equal(null); + }); + it('Not an array error harmonic mean', function() { + var result = stats.harmonicMean(1); + expect(result).to.equal(null); + }); it('Mode', function() { var result = stats.mode([1, 2, 1, 3]); expect(result[0]).to.equal(1);