exercism-elixir/high-school-sweetheart/lib/high_school_sweetheart.ex
2022-01-31 09:28:22 -04:00

29 lines
806 B
Elixir

defmodule HighSchoolSweetheart do
def first_letter(name), do: name |> String.trim() |> String.first()
def initial(name), do: "#{name |> first_letter |> String.upcase()}."
def initials(full_name) do
[first, last] = full_name |> String.split()
"#{initial(first)} #{initial(last)}"
end
def pair(full_name1, full_name2) do
"""
****** ******
** ** ** **
** ** ** **
** * **
** **
** #{initials(full_name1)} + #{initials(full_name2)} **
** **
** **
** **
** **
** **
** **
***
*
"""
end
end