Created
June 26, 2018 13:33
-
-
Save e-mihaylin/b55655bc4c9406d1237b6f5a2bfc4bd7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const decodeMorse = morseCode => morseCode | |
| .trim() | |
| .split` ` | |
| .map(e => morseDictionary[e]) | |
| .join`` | |
| .replace(/\s+/g, ' '); | |
| const morseDictionary = { | |
| '...---...': 'SOS', | |
| '-.-.--': '!', | |
| '.-.-.-': '.', | |
| '.-': 'A', | |
| '-...': 'B', | |
| '-.-.': 'C', | |
| '-..': 'D', | |
| '.': 'E', | |
| '..-.': 'F', | |
| '--.': 'G', | |
| '....': 'H', | |
| '..': 'I', | |
| '.---': 'J', | |
| '-.-': 'K', | |
| '.-..': 'L', | |
| '--': 'M', | |
| '-.': 'N', | |
| '---': 'O', | |
| '.--.': 'P', | |
| '--.-': 'Q', | |
| '.-.': 'R', | |
| '...': 'S', | |
| '-': 'T', | |
| '..-': 'U', | |
| '...-': 'V', | |
| '.--': 'W', | |
| '-..-': 'X', | |
| '-.--': 'Y', | |
| '--..': 'Z', | |
| '': ' ' | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment