Skip to content

Commit 783f7e6

Browse files
committed
fix: correct median test output and remove unnecessary comments
1 parent c60bbdf commit 783f7e6

2 files changed

Lines changed: 14 additions & 29 deletions

File tree

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,8 @@
1-
/* Describe the median, or explain why there isn't one
2-
3-
calculateMedian is given to you at the top of describe-median.js. It throws
4-
when it can't calculate a median. Don't change it.
5-
6-
Implement describeMedian, which calls calculateMedian and returns a sentence
7-
instead of crashing.
8-
9-
E.g. describeMedian([1, 2, 3]), target output: "The median is 2"
10-
E.g. describeMedian([]), target output: "Could not calculate a median: calculateMedian requires a non-empty array"
11-
12-
You'll need a try/catch block for this. The catch block must use the error's
13-
message, so the caller can see what went wrong.
14-
*/
15-
161
const describeMedian = require("./describe-median.js");
172

18-
// Acceptance criteria:
193

20-
// Given an array of numbers
21-
// When passed to describeMedian
22-
// Then it should return "The median is " followed by the median
23-
// Delete this test.todo and replace it with a test.
244
test('given [1, 2, 3], returns "The median is 2"', () => {
25-
expect(describeMedian([1, 2, 3])).toBe("Tne median is 2");
5+
expect(describeMedian([1, 2, 3])).toBe("The median is 2");
266
});
277

288
test("returns a sentence for an empty array", () => {
@@ -36,11 +16,3 @@ test("return a sentence for a non-array", () => {
3616
"Could not calculate a median: calculateMedian requires an array of numbers"
3717
);
3818
});
39-
40-
// Given an empty array
41-
// When passed to describeMedian
42-
// Then it should return "Could not calculate a median: calculateMedian requires a non-empty array"
43-
44-
// Given something that isn't an array of numbers, e.g. "banana"
45-
// When passed to describeMedian
46-
// Then it should return "Could not calculate a median: calculateMedian requires an array of numbers"

‎prep/doubleAllNumbers.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function doubleAllNumbers() {
2+
let doubledNumbers;
3+
4+
for (let n of numbers) {
5+
doubledNumbers.push(n * 2);
6+
}
7+
8+
return doubledNumbers;
9+
}
10+
11+
const myNums = [10, 20, 30];
12+
doubleAllNumbers(myNums);
13+
console.log(myNums);

0 commit comments

Comments
 (0)