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.
i wonder why this very simple solution doesn't get nearly as much "best practice" than the other one above there >^.^<
This comment is hidden because it contains spoiler information about the solution
I think that +v ?? v would be more accurate.
?
Wow! Great job!
Nice
What's the extra space at the beginning for?
Nice, I forgot that
NaN
is a falsy valueclever
Absolute Genius.
Comparing that with my solution, especially knowing that this was a 7kyu kata, makes me seriously doubt my own rank :'D
Made me learn about \b though, i guess i would have come up with something prettier if i knew about it ..?
Cached version of matrix.length and thus faster.
In my opinion
-1 for i
-1 for forEach rather than map ( the behavior of map is more verbose than modifying an object and expecting it to be modifed in the original array )
however, i am sure the forEach is more performant, if only marginally.
Why use
width
instead of just usingi < matrix.length
?Update: I downloaded Firefox 29 on OS X, typed +"0" in the console and it returned 0
To double chech I copied the whole function and run it like this: sortDict({1:5,3:10,b:2,6:3,0:8})
The "0" was returned as a string in the array.
So now I see that if we define "0" in a variable zero and then compare +zero || zero it returns "0" and that is the case even in the newest browsers and on Node 5.1
As pointed in another answer, the best way to do it is >> isNaN(k) ? k : +k
The way I tested this on Node 5.1 and Chrome 48 it worked fine. I tried +"0" and it returned 0
Do you think this because the V8 engine in the newest version of Node and Chrome use ECMAScript6?