Covert String to Title Case in Typescript and Javascript

Need to covert the string to Title Case. Copy paste the simple snippets.

Typescript

Javascript