Using the String toUpperCase() Method in Node.js
How do you use the toUpperCase()
method to convert a string to all uppercase letters using Node.js?
The string.toUpperCase()
function converts a string to all uppercase letters in Node.js. It doesn't change anything else about the original string and doesn't take any parameters.
In this article, we'll give you a quick rundown on how to use it and provide a few code examples.
Here's a code example of using the method:
const yourString = "Dogs are better than cats."
yourString.toUpperCase()
// output: "DOGS ARE BETTER THAN CATS."
As you can see, the toUpperCase()
method returns the value of the string but in all uppercase. And the effect is applied to the entirety of the given string.
Here's another example, but with an original string that has a wide mix of lowercase and uppercase letters in it:
const yourString = "DoGs aRe BEttER than CATS."
yourString.toUpperCase()
// output: "DOGS ARE BETTER THAN CATS."
And you should see that it works the same as before! Notice that each letter is transformed to uppercase, regardless of how many lowercase letters were in the string or where they were located.
Thanks for reading and happy coding!