Created
November 8, 2016 02:08
-
-
Save matt297/aae5a288360d980feda262d792f3d3ae to your computer and use it in GitHub Desktop.
Lighthouse Labs - Intro to Web Dev - W3D1 - Oct 2016 Cohort
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
def map_letters_to_numbers(user_input) | |
user_output = "" | |
user_input.upcase! | |
if user_input.length == 10 | |
user_input.each_char do |letter| | |
case letter | |
when("A".."C") then user_output += "2" | |
when("D".."F") then user_output += "3" | |
when("G".."I") then user_output += "4" | |
when("J".."L") then user_output += "5" | |
when("M".."O") then user_output += "6" | |
when("P".."S") then user_output += "7" | |
when("T".."V") then user_output += "8" | |
when("W".."Z") then user_output += "9" | |
end | |
end | |
puts user_output | |
else | |
puts "You didn't enter 10 characters" | |
end | |
end | |
map_letters_to_numbers("abcdefghij") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment