- Use String.prototype.replace() to match the first character of each word and String.prototype.toUpperCase() to capitalize it.
//#Source https://bit.ly/2neWfJ2 const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase()); console.log(capitalizeEveryWord('hello world!'));
Improve this sample solution and post your code through Disqus
What is the difficulty level of this exercise?
const name = 'Owen'; console.log(name());
The variable name holds the value of a string, which is not a function, thus cannot invoke.
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework