Ad
  • Custom User Avatar

    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.

  • Custom User Avatar

    The first option, your example is given in the description.

    'foo9 -> foo10'

  • Custom User Avatar

    super interesting and helpful, thank you very much!

  • Default User Avatar

    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 returns undefined, but undefined is not a string, so it can't compile. Logically, we know that that can't really happen, because all possible values of bmiCalc are covered by all of your if conditions, but the compiler isn't that smart. The compiler only sees that there are a bunch of if conditions, and there is no return value specified if all if conditions are false. Alternatively, you can fix this by putting something like return "blah" after your last if block.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution