I'm doing a 'morse code' exercise and running into some difficulty. I'll skip posting the hash I created that stores the code and the letter.
The morse code in the method call has 3 spaces between the 'words' Example -
decodeMorse('.... . -.-- .--- ..- -.. .')
My strategy was to split the words first using split(/\s\s\s/) which gives me separate arrays for each word, but then those arrays need a split(' ') to get to the letters.
This is my code -
sc = str.split(/\s\s\s/)
sc.each do |string|
string.split(' ').map {|key| morsecode[key]; }
It works okay, but I'm left with two arrays at the end:
=> ["h", "e", "y"]
=> ["j", "u", "d", "e"]
Normally, if I had two or more arrays that had assigned variable names I would know how to concat them but what I've tried and searched on hasn't changed the situation. Obviously all I get from join('') is the two words together with no space between them.