practice-problems-1/comments/11-most-common-letter.rb
# Write a method that takes in a string. Your method should return the
# most common letter in the array, and a count of how many times it
# appears.
#
# Difficulty: medium.
Write a method that takes in a string. Your method should return the
most common letter in the array, and a count of how many times it
appears.

medium.
Write a method that takes in a string . Your method should return the most common letter in the array and a count of how many times it appears . medium .
def most_common_letter(string)
  count = 0                         
  letter = ""                       
  for i in string.split('')         
      if string.count(i) > count    
          letter = i                
          count = string.count(i)   
      end
  end
  return [letter,count]             
end
def most_common_letter ( string ) count = 0 letter = "" for i in string . split ( '' ) if string . count ( i ) > count letter = i count = string . count ( i ) end end return [ letter , count ] end
Write a method that takes in a string.
Write a method that takes in a string .
# return later, holds result # return later, holds result #loop through string's letter #if the the number of times a letter occurs is greater than the current overall count.... #set letter  #set count #return letter and count is required format
string
<not_specific>