JavaScript String toUpperCase() Method

Last updated on February 20, 2023 by Ayaz Ali Shah

The toUpperCase() method converts the string into uppercase. For example, if the string is javascript then the toUpperCase() method would return JAVASCRIPT. It doesn’t accept any parameter and can be accessed through do notation.




It doesn’t need any parameter, it attaches directly to a string that needs to be converted.

Example 1

Let’s create a string that should contain a lowercase value,


Next, attach the toUpperCase() method to convert it into uppercase.


In this example, the toUpperCase() method is attached to the string that converts it into uppercase. You can use the console.log() function to print the result in the console.


Example 2

Create a variable with the let keyword and assign a lowercase string value to it.

let favoriteColor = "black";

In the next line, attach the toUpperCase() method to the variable with the dot.

// Output: BLACK

It converts the variable’s value to uppercase, and in the output, we get the converted value. You can print the converted value in the console through the below example,


Share on:

Related Posts