Created
December 25, 2016 16:27
-
-
Save railsstudent/e3edc7dbc4747b63a249671bd2566fca 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
decodeMorse = function(morseCode){ | |
var decodeString = ''; | |
var morseCodeWords = morseCode.split(' '); | |
for (var i in morseCodeWords) { | |
var morseCodeArray = morseCodeWords[i].split(' '); | |
for (var j in morseCodeArray) { | |
if (MORSE_CODE[morseCodeArray[j]] !== undefined) { | |
decodeString += MORSE_CODE[morseCodeArray[j]]; | |
} | |
} | |
decodeString += ' '; | |
} | |
decodeString = decodeString.trim(); | |
return decodeString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks, this was helpful