Solution Review: Join Two Strings

The solution to Challenge: Join Two Strings.

We'll cover the following


iex>​ prefix = f​n​ prefix -> ​fn​ str -> ​"#{prefix} #{str}"​ e​nd​ e​nd
iex>​ mrs = prefix.(​"Mrs")​
iex>​ mrs.(​"Smith")​ 
"Mrs Smith"
iex>​ prefix.("​Elixir"​).("​Rocks"​)
"Elixir Rocks"
  • In the first command, we’re making a prefix function that takes a string as a parameter. It returns another function that also takes a string as a parameter.

  • In the second command, we’re passing Mrs as an argument to the prefix function.

  • In the third command, we’re passing Smith as an argument to mrs function, which will join both strings.

  • In the last command, we’re calling the prefix function by passing both strings at the same time.

Get hands-on with 1200+ tech skills courses.