We're a place where coders share, stay up-to-date and grow their careers.
Came up with this Elm solution while I was procrastinating at work today:
capitalizeFirstLast : String -> String capitalizeFirstLast input = let capitalizeFirst = String.left 1 >> String.toUpper capitalizeLast = String.right 1 >> String.toUpper lowercaseMiddle = String.slice 1 -1 >> String.toLower transform word = if String.length word < 2 then String.toUpper word else capitalizeFirst word ++ lowercaseMiddle word ++ capitalizeLast word in String.words input |> List.map transform |> String.join " "
Not overly different from the other solutions here, but neat nonetheless.
Came up with this Elm solution while I was procrastinating at work today:
Not overly different from the other solutions here, but neat nonetheless.