- 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?
Test your Programming skills with w3resource's quiz.
Returns the difference (in days) between two dates
const tips_DiffBetweenDates = (dateInitial, dateFinal) => (dateFinal - dateInitial) / (1000 * 3600 * 24); console.log(tips_DiffBetweenDates(new Date('2020-05-13'), new Date('2020-06-05')));
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- 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