toLowerCase method that returns a string without any uppercase letters. Similarly, we have the
toUpperCase method which returns us a string representation of the given string without any lowercase letters. So essentially both these methods take a string and convert it into a different representation.
That’s where these methods (
toUpperCase) comes in. These methods allow us to convert a string to all lowercase and all uppercase, respectively.
In this article, we’ll explore how to use the
Now strings, as we know, represents a sequence of characters that joined together. Strings can include things like letters, symbols, numbers, and white spaces.
- Single Quotes (”)
- Double Quotes (“”)
- Backticks (“)
Single and double quotes can be used interchangeably, although you should keep your usage of either of these in a consistent manner throughout your program.
So first we have the
toUpperCase method that converts a string to uppercase letters.
toUpperCase does not change the value of a string, instead it takes a copy of the string, mutate that by converting each character of that copied string into its uppercase form and then eventually return that instead of returning the original string.
toUpperCase method as you can see from the above example does not take any argument. It is just applied as a method on the string that we want to transform so basically using the dot operator. This then returns us a copy of the string with all characters in uppercase.
toLowerCase method converts a given string into its lowercase representation. Like the
toUpperCase method, it does not alter the original string. Instead, it simply makes a copy of the original string and mutate that so basically converting each of the given characters of the string into its lowercase representations.
toLowerCase method instead turns the string into its lowercase representation.
In this guide, we discussed how we can make use of the
toLowerCase method to convert a string to all-uppercase and all-lowercase, respectively.
So this is it for this article. Thanks for reading.