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.
This is one of those kata that even if you understand it, it will not work unless you write it the right way, with no clue in the description.
For js this would not work until I used .map to not modify the original inputs.
The first option, your example is given in the description.
'foo9 -> foo10'
super interesting and helpful, thank you very much!
It's because in typescript, all code paths must have a return value that matches the expected return type. In your original example, what if all of your
if
conditions are false? If that happens, there is no return value, so it returnsundefined
, butundefined
is not a string, so it can't compile. Logically, we know that that can't really happen, because all possible values ofbmiCalc
are covered by all of yourif
conditions, but the compiler isn't that smart. The compiler only sees that there are a bunch ofif
conditions, and there is no return value specified if allif
conditions are false. Alternatively, you can fix this by putting something likereturn "blah"
after your lastif
block.This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution