Skip to content

Commit f64fe71

Browse files
committed
removed redundant check for mean. added test for floating number.
1 parent f5247f1 commit f64fe71

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎Sprint-1/implement/mean.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function calculateMean(list) {
2-
if (!Array.isArray(list) || list === "") {
2+
if (!Array.isArray(list)) {
33
throw new Error("calculateMean requires an array of numbers");
44
}
55

‎Sprint-1/implement/mean.test.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ describe("calculateMean", () => {
4242
expect(calculateMean([10, 20.5, -10, 30.5])).toEqual(12.75);
4343
});
4444

45+
it ("returns for [1.2, 0.6, 0.005]", () => {
46+
expect(calculateMean([1.2, 0.6, 0.005])).toBeCloseTo(0.6017);
47+
48+
});
49+
4550
// Given an empty array
4651
// When passed to calculateMean
4752
// Then it should throw Error("calculateMean requires a non-empty array")

0 commit comments

Comments
 (0)