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.
Because
this
is not set at function call (usingFunction.prototype.call
and such) it'snull
, which becomes the global scope at non-strict mode:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this#Function_context
So this is essentially another solution that uses global object.
hope this is sarcasm
I only wrote the original Clojure kata, which is why the description may seem a little vague.
I don't think the ES6 appraoches are necessary, they are just popular since people have been learning ES6.
It would have been nice if the author of the JS kata elaborated a little more, but I probably wouldn't do the best job of it, so I'll leave it as is for now.
The kata proposes an algorithm to see if a number is divisible by 13 and that is all; the aim is not to give a mathematical lesson... To have a mathematical proof or informations you can google "rules of divisibility". Maybe you have a good explanation to propose? Anyway thanks for the feedback.
If the actual object field was called
name
you could use eitherobj['name']
orobj.name
. However,name
is a variable that represents some other value in this case.Operands of logical operators are converted to boolean only to determine which value to return. But the actual return value is obtained from original, non-converted ones.
E.g. in Java you can write the following and nothing is converted.
MDN: Logical Operators
The test cases are always precise because they provide an input and a specific solution that must be returned. It is not the fault of the test case itself but I'm guessing it could be a rounding issue embeded within the code. If both versions pass the tests then essentially they are both correct, even if one method is more precise than the other.
map creates a new array with new items. that is not the goal as I understand it.