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.
The left side of the comparison determines if the variable is NOT an "existing"
true
or an "integer""not a decimal
", the result isundefined
If the left of the comparison fails, then we move to the right comparison
If the integer is odd then return false, else return true.
Because this is kumite. Here it's about showing off skills related to the knowledge of tricks to reduce the length of the code as much as possible, I think. Of course, in "normal" code readability is very important.
Why you dont return simple undefined instead od {}.a ?
I mean:
isEven=n=> n%1==0 ? !(n%2) : undefined
and this is more readability. When you put some whitespace beetween
Good point! I shouldn't blindly trust tests....
I completely agree that code readability is very important. However, analyzing the struggle at the kumite, I noticed that "shorter is better", this criterion guided me. Thanks for your comment.
This code says that division by zero is possible:
This is because
5 % 0
returnsNaN
and!NaN
is truthy value.More predictable code:
Also note whitespaces around
%
. Google Style Guide recomends this notation for the sake of readability.0
Well done! I didn't know the trick {}.a for undefined...
return isDivisible //:)
Kata forced minimum length of code: 90. Weird...