Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
yeah, since the
Array
technically is iterable as well; might wait for more opinions for that matter before adding the actual check thoughdone
🤦 that was embarassing. thanks for your help :)
Your current
unshift()
function will actually move the existing values by the length of the original listlist.length
, not the amount of added by unshift elementselements.length
; since thefilter
fixed tests are using the list afterunshift
tests and other, it'd be broken.there should be a check that
List
is iterable. although it may invalidate many solutions, i think it would make the kata much more interestingthe initial code should be a
class
, to keep up with the timescan you check the
Ensuring the original list is not changed
test ? I am fairly certain that myfilter
implementation is pure, but i getlist[3] has been modified: expected 10 to equal 2
. it seems as though this test is actually checking the original list against the filtered oneThe fun part is,
Array.prototype.functionName = undefined
won't work because the other third-party components will definitely use it (chai or describe/it, for example), thus throwing an error;Array.prototype.functionName = function() {}
sometimes works as intended, but sometimes it'll throwResponse received but no data was written to STDOUT or STDERR.
. (shift
function will not throw that, but the tests won't be actually checked, although the describe/it sections' titles will be shown normally without any details XD )Reworked the tests so that the error messages should be more concise now.
The error messages are completely useless.
Double the satisfaction. Once with some good coding practice, and a second time seeing the creative ways used to cheat 😋
Yes, my solution follows the task literally. But since title is to implement the
List
and there are descriptions of what methods should do still I think solution should work as if noArray
existed at all. We can not remove it totally, but we can develop test criterias which will check if this requirement is fulfilled. For example, remove all methods fromArray
prototype and as you said check return types of methods.But maybe I'm just not satisfied with Kata's complexity and digging to deep. :) Then again if we follow the rules literally,
.filter()
should work exactly asArray
's one does, thus return anArray
.Pfff... who knows? ^^
You're returning an object with a length property, values on numerical keys, and method getters pointing to Array methods.
It's as close to an array as you'll come, but it's an object which is not an array. It's legal. It's not a cheat.
It may feel like a cheat, but because after all everything is an object, how are you going to distinguish a too simple one from a sufficiently complicated one, and where do you draw the line?
I have no better solution.
Edit: Hmm ..
.filter()
doesn't return aList
; it returns anArray
. (More solutions are guilty of this.) Would that be a fair requirement? (It's not explicitly specified.)Why the downvote? What did I do wrong? If I don't know, I can't fix it.
(Aimed at downvoter, not necessarily at OP.)
Loading more items...