How to convert string to uppercase in JavaScript

Share the post

Hello All, In JavaScript we can easily do the uppercase using the default method toUpperCase(). We can see this functionality using a simple example. We will save the string in one variable & then apply the method toUpperCase() & it will easily convert all string values in uppercase format.

String to Uppercase in JavaScript example

let str = "convert this to uppercase";
str = str.toUpperCase();
alert(str);

//output : CONVERT THIS TO UPPERCASE

This is how we can able to convert string to uppercase in JavaScript.

String to Uppercase in CSS example

<!DOCTYPE html>
<html>
 <head>
    <style>
.uppercase {
          text-transform: uppercase;
       }

    </style>
</head>
<body>

<div class="uppercase">

convert this to uppercase

</div>

</body>
</html>



//output : CONVERT THIS TO UPPERCASE

This is how we can able to convert string to uppercase in CSS.

Leave a Comment