Program to convert the first character of every word in a string into uppercase
Here's how the program works
A function convert() is defined as taking a string as an input.
- The string gets divided into an array of words using the split() method.
- The code then iterates to find the first character of every word. After finding the first character, it gets converted to its uppercase character if it is in lowercase.
- Then it iterates again checking if any non-first character of a word is upper-case, it converts them into their lower-case character.
- After the completion of the task, the split string gets merged using the join() method
- The result gets printed using the document.write function.