Skip to content

Commit 0a85b51

Browse files
Renamed from AverageMean to calculateMean
1 parent ceecb2a commit 0a85b51

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Maths/AverageMean.ts renamed to Maths/calculateMean.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/**
2-
* @function AverageMean
2+
* @function calculateMean
33
* @description This script will find the mean value of a array of numbers.
44
* @param {number[]} numbers - Array of numeric values
55
* @return {number} - mean of input numbers
66
* @see [Mean](https://en.wikipedia.org/wiki/Mean)
7-
* @example AverageMean([1, 2, 4, 5]) = 3
8-
* @example AverageMean([10, 40, 100, 20]) = 42.5
7+
* @example calculateMean([1, 2, 4, 5]) = 3
8+
* @example calculateMean([10, 40, 100, 20]) = 42.5
99
*/
1010

11-
export const AverageMean = (numbers: number[]): number => {
11+
export const calculateMean = (numbers: number[]): number => {
1212
if (numbers.length < 1) {
1313
throw new TypeError("Invalid Input");
1414
}
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
import { AverageMean } from "../AverageMean";
1+
import { calculateMean } from "../calculateMean";
22

33
describe("Tests for AverageMean", () => {
44
it("should be a function", () => {
5-
expect(typeof AverageMean).toEqual("function");
5+
expect(typeof calculateMean).toEqual("function");
66
});
77

88
it("should throw error for invalid input", () => {
9-
expect(() => AverageMean([])).toThrow();
9+
expect(() => calculateMean([])).toThrow();
1010
});
1111

1212
it("should return the mean of an array of consecutive numbers", () => {
13-
const meanFunction = AverageMean([1, 2, 3, 4]);
13+
const meanFunction = calculateMean([1, 2, 3, 4]);
1414
expect(meanFunction).toBe(2.5);
1515
});
1616

1717
it("should return the mean of an array of numbers", () => {
18-
const meanFunction = AverageMean([10, 40, 100, 20]);
18+
const meanFunction = calculateMean([10, 40, 100, 20]);
1919
expect(meanFunction).toBe(42.5);
2020
});
2121

2222
it("should return the mean of an array of decimal numbers", () => {
23-
const meanFunction = AverageMean([1.3, 12.67, 99.14, 20]);
23+
const meanFunction = calculateMean([1.3, 12.67, 99.14, 20]);
2424
expect(meanFunction).toBe(33.2775);
2525
});
2626

2727
it("should return the mean of an array of numbers, including negatives", () => {
28-
const meanFunction = AverageMean([10, -40, 100, -20]);
28+
const meanFunction = calculateMean([10, -40, 100, -20]);
2929
expect(meanFunction).toBe(12.5);
3030
});
3131
});

0 commit comments

Comments
 (0)