Build a function, ‘morse_encode(str)’ that takes in a string (no numbers or punctuation) and outputs the morse code for it. See http://en.wikipedia.org/wiki/Morse_code. Put two spaces between words and one space between letters.
You’ll have to type in morse code: I’d use a hash to map letters to codes. Don’t worry about numbers.
I learned the difference between global variables and Ruby constants while solving this problem. They both serve similar purposes but global variables’ values can be changed while Ruby constants cannot. Also, constants are written in all uppercase and global variables start with “$”.
Another thing to remember is how to retrieve key/value from hash. Here’s a handy cheat sheet of shortcuts for Ruby hashes.