You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d49e0c2
Browse filesBrowse the repository at this point in the historyBrowse files
Add mean and describe-median katas to implement, and change the existing
fix/implement exercises to throw on bad input instead of ignoring it,
matching the updated Sprint 1 prep.
Copy file name to clipboardExpand all lines: Sprint-1/implement/max.test.js
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
In this kata, you will need to implement a function that find the largest numerical element of an array.
4
4
5
5
E.g. max([30, 50, 10, 40]), target output: 50
6
-
E.g. max(['hey', 10, 'hi', 60, 10]), target output: 60 (sum ignores any non-numerical elements)
6
+
E.g. max(['hey', 10, 'hi', 60, 10]) throws Error("findMax requires an array of numbers") (max can't compare non-numerical elements, so it shouldn't guess)
7
7
8
8
You should implement this function in max.js, and add tests for it in this file.
9
9
@@ -34,10 +34,10 @@ test.todo("given an empty array, returns -Infinity");
34
34
// When passed to the max function
35
35
// Then it should return the largest decimal number
36
36
37
-
// Given an array with non-number values
37
+
// Given an array containing a value that isn't a number
38
38
// When passed to the max function
39
-
// Then it should return the max and ignore non-numeric values
39
+
// Then it should throw Error("findMax requires an array of numbers")
40
40
41
-
// Given an array with only non-number values
41
+
// Given something that isn't an array at all, such as "hey", 42 or no argument
42
42
// When passed to the max function
43
-
// Then it should return the least surprising value given how it behaves for all other inputs
43
+
// Then it should throw Error("findMax requires an array of numbers")
0 commit comments