Morse Code Decoded

Published by Matt in

Create a function that takes a string (morse code) as an argument and returns an unencrypted string.

Examples

decodeMorse(".... . .-.. .--.   -- .   -.-.--") ➞ "HELP ME !"

decodeMorse("-.-. .... .- .-.. .-.. . -. --. .") ➞ "CHALLENGE"

decodeMorse(". -.. .- -... -... .. -   -.-. .... .- .-.. .-.. . -. --. .") ➞ "EDABBIT CHALLENGE"

Notes

  • Return values are all uppercase.
  • Input string can have digits.
  • Input string can have some special chararacters (e.g. comma, colon, apostrophe, period, question mark, exclamation mark).
Watch a quick demo on how Edabit works.