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.
Stackoverflow post referenced states that switch-immediate (which this is) is actually the fastest.
Also it's eight years old now and js uses a totally different optimizing compiler in 2020.
You shouldn't be using var.
That's all. Peace!
While it depends on the environment and the specific case, the safest bet for performance nowadays is switch over if-else.
https://jsperf.com/if-switch-lookup-table/113
This comment is hidden because it contains spoiler information about the solution
In High Performance JavaScript, Nicholas Zakas talks about conditionals vs. if-else statements:
https://www.safaribooksonline.com/library/view/high-performance-javascript/9781449382308/ch04s02.html
Why not use .every()
You cannot within
.map()
, as areturn
statement just exit the relevant function, in this case the one inside the.map()
method.If that is your goal, you might wish to use something like an ordinary loop, iterating over the array.
This comment is hidden because it contains spoiler information about the solution
Haven't met them before, thank you!
It's a ES6 feature, enabled via Babel.
Hello, what does the
=>
mean? Is it kind of an alternative function notation?That's great to hear!
Thank you, should have looked closer.
It can be found in your profile:
http://www.codewars.com/users/mark-outlast/comments
Nice solution!
I was also contemplating a switch statement, but the computational overhead is allegedly very severe and simple if statements are preferable. Details: http://stackoverflow.com/a/12259830
Loading more items...