object TitleCaseConverter {
def toTitleCase(str: String): String = {
str.split(" ").map(_.capitalize).mkString(" ")
}
def main(args: Array[String]): Unit = {
val str = "In the beginning there was nothing, which exploded."
val titleCased = toTitleCase(str)
println(titleCased)
}
}
/*
run:
In The Beginning There Was Nothing, Which Exploded.
*/