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 observation. I added the checks for zeros.
Good catch. A test case should be added to check for zero values.
2 cents: for reading pleasure, if you have a return in the middle of a function, put it at least at the beginning of the line - there it is a little bit more visible.
Besides that I also tend to "break out" of functions. Especially in cases like this - the "return -1" at the end clearly signifies a default value, so there has to be another return...