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.
nice refactoring
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?
This comment is hidden because it contains spoiler information about the solution
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.For the quadratic equation: 0x2 + 0x + 0, expected: cannot find x; got: x = undefined
How is this different?
toFixed() returns a 'string' and you need to return a number.
This comment is hidden because it contains spoiler information about the solution
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?
Second test case incorrect. Useless kata.
Can anyone explain how type checking works here? Top solutions don't check for number's type. They just check for " > 0". Does it cover every possible case? So whatever input we give, if it's value is > 0, then it's a number?