Computer >> Computer tutorials >  >> Programming >> Javascript

How to convert a string into upper case using JavaScript?


To convert a string into upper case, use the JavaScript toUpperCase() method. This method returns the calling string value converted to uppercase.

Example

You can try to run the following code to convert a string into the upper case −

<html>
   <head>
      <title>JavaScript String toUpperCase() Method</title>
   </head>

   <body>
      <script>
         var str = "demo text";
         document.write(str.toUpperCase( ));
      </script>
   </body>
</html>