Update AverageMedian.js and added AverageMedian.test.js

This commit is contained in:
qingwen23
2021-07-19 12:44:48 +08:00
parent 188c6f6537
commit 04b71c337a
2 changed files with 24 additions and 5 deletions

View File

@@ -0,0 +1,21 @@
import { averageMedian } from '../AverageMedian'
test('should return the median of an array of numbers:', () => {
const medianValue = averageMedian([1, 2, 6, 4, 5])
expect(medianValue).toBe(4)
})
test('should return the median of an array of numbers:', () => {
const medianValue = averageMedian([8, 9, 1, 2, 5, 10, 11])
expect(medianValue).toBe(8)
})
test('should return the median of an array of numbers:', () => {
const medianValue = averageMedian([15, 18, 3, 9, 13, 5])
expect(medianValue).toBe(11)
})
test('should return the median of an array of numbers:', () => {
const medianValue = averageMedian([1,2,3,4,6,8])
expect(medianValue).toBe(3.5)
})