Editing strings with built-in JavaScript methods
While learning some very useful strings methods today, I decided to practice them together with short if-else syntax I discovered yesterday.
- This function re-format string begins with capital letter followed by lowercase letters, using toUpperCase and toLowerCase methods:
- This function cuts the end of a string, if it’s longer then the maximum number of symbols, using length and slice methods:
- This function checks, if the phrase contains spam words, using indexOf and toLowerCase methods:
You may check all these functions with working examples at JSFiddle or below by clicking “Result”: