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.
you can also use the loose operator just in case someone mistakenly types the number as a string.
love this one
It is best practice to never use double equals
No. The requirement is to 'filter out the strings'. We don't really care if the left overs are numbers, objects, or anything else for that matter. Just don't include the strings!
This comment is hidden because it contains spoiler information about the solution
@schm0 Not sure what you mean - this is native JS, not Underscore.
Is there anything similar that doesn't lean so heavily on underscore? I don't mind learning more about underscore, just looking for something more focused on native javascript.
This comment is hidden because it contains spoiler information about the solution
circleArea("1")
should returnfalse
as "If the radius is not positive or not a number, return false.", but it returns3.14
.toFixed
does round.The "Boolean primitive" is a boolean. ToNumber is well defined on booleans. And isNaN works in terms of
ToNumber
.That being said, the kata is underspecified at that point, as it isn't clear if the type of the argument should be checked. After all, it says only that "[i]f the radius is [...] not a number, return
false
". And that can be easily interpreted asisNaN
returns true. The the abstract relational comparison algorithm makes sure that the inintial comparison is true if and only ifradius
was actually a number (or convertable withToNumber
).The solution provided by ColbyDauph et al is therefore perfectly valid for any input, as long as you concur with the definition of "number" given above. If you object that defintiion, suggest a kata edit to clear that issue.
Passing true to the function should result in false (as the the Boolean primitive is NaN), however the result returned is 3.14
Good Kata, always like some recursion to start the day.
Im just curious what the point of having the requirement of one recursive call per character is? My solution halves that and it seems a bit odd refactoring my code to make it be much less efficient. I suppose it makes me think about a different type of solution which is always good!
dcba, like you were reading it right to left
Having the same problem!
Loading more items...