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.
OP solved it, closing
What do you mean the wrong way? Isn't that how we're supposed to do it? I mean, there's no way you can access a variable of an inner function without receiving it directly from them (by return) or forcing them to leak the variable onto the global scope (like what you did)
Yes, you pass a sample in the form of two arrays which you have to create yourself to
scales.getWeigh()
and it returns a response. For example, if ball 1 is the heavy ball, the following will happen:Power and root are inverse operations, so your myPow function can with a very small modification be used to compute root instead.
@VladimirZd: You only showed
myPow
, but you didn't show us how you used that function. That might be an integral part. The numbers may differ at the 12th digit, so it would be interesting to see your actual complete solution.Nope; I didn't calculate power nor did any other solutions I saw. Your function works " "fine" " , I mean it returns wrong result because of JS floating point issues.
Passing solutions compute more "directly" the root and eventual remaining floating point issues are handled by an
assertFuzzyEquals
function bkaes-san wrote for us ( どうもありがとう!Dōmo arigatō! ).Are-you trying to find the
nth power of x
?I thought the kata was about the
nth root of x
.Uhm, yes, I've published this kata ;). Your solution seems fine, but could you post an actual error message?
That's interesting - could you add your code as comment? Don't forget to mark it as a spoiler and add proper formatting (e.g. indent with 4 spaces).
Can you explain what is the strange result you are talking about? Yes I think it is working, it is not very difficult.
I have added the few tests that you have recommended in the submit tests section.
Thanks, I have updated to say that you only need to truncate and not round the number.
It seems your
.isString
method doesn't recognize a string created this way:new String('a new String')
ie usingString
as constructor.By the way, there're more than 50 other test cases after this one.
This kata is average ranked 6 kyu, if you really never used JS before may be you should try to solve easier ones before.