Created
March 30, 2016 18:23
-
-
Save stupeters187/0216ac627cf359f17bd6a7855437ed17 to your computer and use it in GitHub Desktop.
This file contains 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
require 'pry' | |
def count_letters(string) | |
letter_hash = Hash.new(0) | |
# string.each do |chars| | |
string.split('').each do |i| | |
letter_hash[i] += 1 | |
end | |
# end | |
letter_hash | |
end | |
puts count_letters("lighthouse") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment