Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 602 Bytes

abbreviate_a_two_word_name.md

File metadata and controls

26 lines (19 loc) · 602 Bytes

Description

Write a function to convert a name into initials. This kata strictly takes two words with one space in between them.

The output should be two capital letters with a dot separating them.

It should look like this:

Sam Harris => S.H

patrick feeney => P.F

My Solution

def abbrev_name(name)
  name.split(' ').map{|el| el[0].upcase}.join('.')
end

Better/Alternative solution from Codewars

def abbrev_name(name)
  name.split.map { |s| s[0]}.join('.').upcase
end