mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
Add an algorithm to find mean absolute deviation (#1165)
This commit is contained in:
committed by
GitHub
parent
514c7c4c9f
commit
564ee8527a
16
Maths/test/MeanAbsoluteDeviation.test.js
Normal file
16
Maths/test/MeanAbsoluteDeviation.test.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { meanAbsoluteDeviation } from '../MeanAbsoluteDeviation.js'
|
||||
|
||||
describe('tests for mean absolute deviation', () => {
|
||||
it('should be a function', () => {
|
||||
expect(typeof meanAbsoluteDeviation).toEqual('function')
|
||||
})
|
||||
|
||||
it('should throw an invalid input error', () => {
|
||||
expect(() => meanAbsoluteDeviation('fgh')).toThrow()
|
||||
})
|
||||
|
||||
it('should return the mean absolute devition of an array of numbers', () => {
|
||||
const meanAbDev = meanAbsoluteDeviation([2, 34, 5, 0, -2])
|
||||
expect(meanAbDev).toBe(10.479999999999999)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user