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.
This comment is hidden because it contains spoiler information about the solution
Hey Everyone,
I am new to programming. I approached this kata in javascript with aim to practive object oriented programming and ES6 classes. I spent some time on this kata and I was supper proud with what I came up with. Unfortunatelly my solution did not pass the tests. The one thing I was missing / doing different than the solutins I found here, was to set the direction property on the Array object through the dot notation in stead of the Object.defineProperty method. I played around with both approaches and whenever logging my object to the console I saw the same things in both cases. Could someone explain why this assigning the dir property through the dot notation fails this kata tests? What is the difference when I use the Object.defineProperty function simply specyfing the value in the descriptor?
Your help would be very much appreciated :D
Object.defineProperty is recomending method on JS ? i'm first use
This comment is hidden because it contains spoiler information about the solution
The use of the init parameter is not tested. I see at least one solution passed where the numeric value was inserted, while the behaviour of the
Array
constructor is to set the length of the array to that value.In the same line you may want to conform with the
Array
constructor behaviour when mutliple arguments are given, in which case they are inserted. And then it would be good to also require (and test!) that the Array is sorted at that very moment as well.You changed the Description, but did you change the tests?
You're not afraid to invalidate existing solutions are you ?!?
Fixed it up.
I was having the same thoughts. I'm leaning toward making it more in line with
Array
I'm not sure I like the change to
pop
andshift
, where they do not return the removed value.Returning
this
( sorted or otherwise ) has the advantage of enabling chaining, but this has the disadvantage of losing the removed value entirely and making the fourSortedArray
methods very, very much alike each other.Maybe you should invent a version of
SortedArray
that's more unlikeArray
. ( Maybe only in a next version of this kata .. )Thought:
"Currently, that is unspecified" would be the correct answer. Inventing a specification might be a good idea, but there is no reason this must be the
Array.prototype
behaviour. Or the reference solution behaviour.Currently, it returns back an empty array and has no effect. It might be a good idea to bring this inline with Array.prototype and have it return
undefined
. Thoughts?What is the behavior of
pop
/shift
on an empty array?For this version of the kata, no. I'm going to be posting an advanced version of this soon where it will be different.
Is there a difference in behavior between
unshift
andpush
?Not an issue.
Loading more items...