Objective

Create a function to convert a camel-cased string into title case.

Difficulty

Easy

Description

In the exercise JavaScript Strings — Camel Words, we implemented the function getWords() to extract out all the words from a given camel-cased string into an array.

In this exercise, you have to create a function camelToTitleCase() that converts a given camel-cased string into title case using the getWords() function.

As per the title case convention, the words obtained from the camel-cased string must be separated by a space and have the first word's first letter in uppercase.

So for instance, if the string passed to camelToTitleCase() is 'firstChild', where the words are first and Child, the function must return back the string 'First Child'.

Note that if the given string is empty, the function must return back an empty string as well.

Shown below are a couple more examples:

camelToTitleCase('insertHTML')
'Insert HTML'
camelToTitleCase('insertAdjacentHTML')
'Insert Adjacent HTML'
camelToTitleCase('firstHTMLElement')
'First HTML Element'
camelToTitleCase('releaseDate')
'Release Date'
camelToTitleCase('')
''