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 is that solution that makes you kick yourself for not thinking of it. Very elegant.
javascript's value mangling is so frustrating. bugs as idiomatic patterns is something I want to run away from these days.
thats a really clever answer , if you dont know enough slice method dont understand anythink , but this answer teach me about slice method deeply , for ex slice method acting floor method if get the float , thanks a lot
( ͡° ͜ʖ ͡°)
so slice automitacally uses floor on the numbers
Fair enough I guess, each to their own.
I'll take the clearer one and finding out what slice does rather than reading your solution that is much more cluttered and harder to read.
osam bro,,,
@TrapGodd, because it will give wrong answer. E.g. when s.length equals 7 it will give different results:
(7 - 1) / 2 = 3
7 / 2 - 1 = 2.5
The latter is automatically rounded down to 2 by slice method and gives wrong result.
It will give "s" instead of "t" for Testing.
slice requires both parameters as integers and apparently does something like Math.floor() to them automatically.
Math.floor((6 - 1) / 2) = 2
But this returns an array, the kata asked for a string
So elegant!
Hey man, I know im a bit late, but if you somehow recieves this message, for the lower bound, why do you do (s.length-1)/2 instead of (s.length/2 -1) like the upper bound (s.length/2+1)
"(s.length-1)/2"
so for example if the string length is 6 then (6-1)/2 turns into 2? why is that?
this is really shrewd!
Loading more items...