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 thing is, simply replicating the formula in a function is super-easy, so would be kinda pointless, I think.
Minimizing calls to Math.sqrt is a bit overzealous for this problem imo.
Is this question resolved?
The message should say something like "You passed the tests with x calls to Math.sqrt." So it's the total number of calls over all tests, not just from a single call.
Other than that, there may be further ways of reducing the need to call Math.sqrt within your code. It's been a while since I wrote this kata, so I can't remember all the algebra associated with it, but that's probably the problem, anyway. Perhaps someone else can give you further help?
I've added some better messages for the tests now; is it clearer?
If the message says "x = undefined" it means you returned an array with no items, or
undefined
as the first item. If x cannot be found,undefined
should be returned, not an array. I'll try to make this clearer in the test messages.can we check the radius is the number type using "typeof"?if the radius's type is "number",then we can use the if-else again?