There are few ways to solve the challenge. The way you should choose depends on your abilities. One way to approach it is regex. In fact, you could utilize regex with different approaches. You could use regex to locate every word and change its letter to an upper case. You could use the String.replace() method along a proper regex.
Another approach would be to turn the string into an array of “words”, then obviously, loop thru that array and work out each word to have upper case. Or you could loop thru each letter in the initial string and have letters which are start of a word to be upper case(need to figure out how to put that condition!).
Keep in mind strings are immutable, which means you cant directly change parts of them, you need to build a new string with the changed value(s), where array values can be manipulated easier.
Thats the thrill of coding, you can solve one problem many way, just pick a path and see what works best for you, what works best in general. Id say working with strings, regex is most the time the better solution, so its a good skill to have under your belt.
arsheen did not post a solution, but pseudo code for you to modify into real, working JS code.
Instead of regex, he suggests splitting the string into an array of words, then capitalizing each word in the array, then joining them back up. It would work.