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.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
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:
Not overly different from the other solutions here, but neat nonetheless.