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.
'Looks like you've solved it'
Sadly JavaScript doesn't use integers, so this solution will fail if you give it a value of
0.12
.Test cases was fixed a year ago.
If you pass 0.5 to the function, it won't return the negative value;
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
"To compare numbers instead of strings, the compare function can simply subtract b from a."
Few spelling errors in the description could be cleaned up
Tests were included in the wrong box on the edit screen, fixed!
I was baffled why my test cases hadn't come through but realised where the correct input box was on the edit page, thanks for the heads up!
Edited the typo's, thanks!
Just a simple spell check in the description as well as more test cases needed. Otherwise great!
@bkaes Very helpful thank you! Solved it.
@constablebrew Thanks for your help! Solved it.
You should carefully walk through the logic you have built here and consider what the result will be in each possible test case you can imagine. For instance,
remainder(0, -5)
should actually return0
(but it seems I missed that test case in the kata itself). In the case where the input values are equal, your logic ends up returninga || b
, which doesn't make any sense.Because the method will never modify anything. It's defined like this.
Thank you for your help @bkaes. The problem is I don't really understand why it's not modifying it.
Take a look at Array#Iteration_methods to see how to use
Array#some
( * and if maybe there's a better method to solve this kata * )Loading more items...