Skip to main content

Capitalize Words in String

JUNIOR
GlobalLogicLuxoft

Write a function capitalizeWords(str) that capitalizes the first letter of each word in a string.

Words are separated by spaces. The rest of the letters should be lowercase.

Example:

Input: "hello world"
Output: "Hello World"

Examples:

Input 1:{"str":"hello world"}
Output 1:"Hello World"
Input 2:{"str":"javascript is awesome"}
Output 2:"Javascript Is Awesome"

Loading editor...

Run your code to see results

Click the Run button above