turn array of strings into a sentence with ruby -
so need turn array of strings sentence, capitalize first word , add period @ end. have looked everywhere , found bits , pieces nothing specific problem.
what tried far:
array1 = ["this", "is", "my", "first", "post"] def sentence_maker (array) array.join(' ') end
it makes sentence can't figure out how make first word capitalized while keeping others in lower case , add "." @ end of sentence. appreciated.
you below :
array1 = ["this", "is", "my", "first", "post"] def sentence_maker (array) array.join(' ').capitalize << "." end sentence_maker(array1) # => "this first post."
Comments
Post a Comment