simple-exercises/ruby-exercises/benchmark-capitalize.rb
# Write a method that takes in a string of lowercase letters and
# spaces, producing a new string that capitalizes the first letter of
# each word.
Write a method that takes in a string of lowercase letters and
spaces, producing a new string that capitalizes the first letter of
each word.
Write a method that takes in a string of lowercase letters and spaces producing a new string that capitalizes the first letter of each word .
def capitalize_words1(string)
  capitalized = ""
  isfirst = true
  string.each_char do |c|
    if c != " "
      if isfirst == false
        capitalized += c
        next
      end
      capitalized += c.upcase
      isfirst = false
      next
    end
    capitalized += c
    isfirst = true
  end
  capitalized
end
def capitalize_words1 ( string ) capitalized = "" isfirst = true string . each_char do | c | if c != " " if isfirst == false capitalized += c next end capitalized += c . upcase isfirst = false next end capitalized += c isfirst = true end capitalized end
Write a method that takes in a string of lowercase letters and
spaces, producing a new string that capitalizes the first letter of
each word.
Write a method that takes in a string of lowercase letters and spaces producing a new string that capitalizes the first letter of each word .
# c is a space, next c should be capitalized
string
<not_specific>