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.
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.