Story points | 3 |
Hard Prerequisites |
|
These katas are a bit harder than the last bunch. Make use of assertions to help make sure that your code is doing the right thing, and to add readability.
Create two functions:
lettersToMorseCode
morseCodeToLetters
eg:
lettersToMoreseCode("Hi there")
// should return
// ".... .. / - .... . .-. ."
Include the following assertions in your code:
Make sure that when you do this, your code remains clean and DRY. DRY - it’s a thing. Google it.
Admittedly this kata is a little bit contrived. Assertions are great for adding runtime checks to values and adding documentation as code.
For a problem like this one, unit tests are more appropriate.
Add unit tests to your code. Leave the asserions in there just so that we can see that you know how to hit the requirements we laid out. But if you have some passing tests as well that would be sweet.