6 kyu
Arrays are Objects
105MentalAtom
Loading description...
Arrays
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
The chaining methods are not tested completely. See this solution
The sample tests use
assertSimilar
while the submission tests useassertDeepEquals
. These assertions have slightly differing semantics:extend
ingArray
, I pass the full tests but I fail thegetSplit
sample test:JS: Node v14 should be used along with its appropiate assertion tools (Mocha + Chai). Refer to this and this
This description makes zero sense; the expected behavior is extracting the
n
'th element of an array.This is not enforced.
I can't get passed "getSplit" test. My
split
object looks like this:{pass: magicArray, fail: magicArray}
Am I missing something or the tests have issues? I can see that when instance of magicArray is compared with instance of Array, the test suite is creating strings which contain only array elements and then comparing those strings. When comparing objects with magicArrays, it's creating a string out of object and not checking if properties are arrays.
Did you trip over enumerability of methods? Or do you have magicArrays that aren't arrays?
They are arrays, but with extra methods which are ignored when assertSimilar arguments are arrays. When you pass an object containing magicArray to assertSimilar, those extra methods from fn object are not ignored Here is the fail message:
Expected: '{ pass: [ \'a\', \'b\', \'c\' ], fail: [ 1, 2, 3 ] }', instead got: '{ pass: \n [ \'a\',\n \'b\',\n \'c\',\n getFiltered: [Function: getFiltered],\n getRejected: [Function: getRejected],\n getSplit: [Function: getSplit],\n count: [Function: count],\n double: [Function: double],\n multiply: [Function: multiply],\n first: [Function: first],\n last: [Function: last],\n eq: [Function: eq] ],\n fail: \n [ 1,\n 2,\n 3,\n getFiltered: [Function: getFiltered],\n getRejected: [Function: getRejected],\n getSplit: [Function: getSplit],\n count: [Function: count],\n double: [Function: double],\n multiply: [Function: multiply],\n first: [Function: first],\n last: [Function: last],\n eq: [Function: eq] ] } '
I'm getting this failure as well, if the pass/fail properties are not magicArrays then the chainable tests will fail, otherwise the getSplit test will fail. Any suggestions?
EDIT: durr, just needed to define the method props as non-enumerable :)
In
double
andmultiply
:If this is meant to imply the method should mutate the array they're called on, it's not tested that way (and not everyone implements it that way).
Either way, it's unclear.
Shouldn't
testArrayTwo.multiply(2).first().double().double()
returns[2, 2, 2, 2]
instead of[2, 2, 2]
?(
[2].double()
->[2,2]
, then[2,2].double()
->[2,2,2,2]
)Yes, it does so in the test cases - I caught that when I was testing but missed in the description.
That's now updated in the example. Thanks, good spot!