JavaScript

How to Convert Strings to Uppercase in JavaScript

To convert a lowercase string to an uppercase string, we use the method toUpperCase() in javascript. This method does not affect numbers, special characters, and alphabets that are already in upper case.
 

Program to Convert Strings to Uppercase in JavaScript
<!doctype html>
<html>
   <head>
      <script>
         function maj() {
           var str = "Welcome to StackHowTo!";
           var res = str.toUpperCase();
           document.getElementById("text").innerHTML = res;
         }
      </script>
   </head>
   <body>
      <p>Welcome to StackHowTo!</p>
      <button onclick="maj()">Click here to convert the string</button>
      <p id="text"></p>
   </body>
</html>
Result

Welcome to StackHowTo!

mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *