Skip to content
Related Articles

Related Articles

JavaScript String toUpperCase() Method

Improve Article
Save Article
  • Last Updated : 01 Dec, 2022
Improve Article
Save Article

JavaScript String toUpperCase() method converts the entire string to Upper case. This method does not affect any of the special characters, digits, and the alphabets that are already in the upper case. 

Syntax: 

str.toUpperCase()

Return value: This method returns a new string in which all the lowercase letters are converted to uppercase.

Below is an example of the String toUpperCase() Method.

Example 1: 

JavaScript




<script>
    function func() {
        var str = 'geeksforgeeks';
        var string = str.toUpperCase();
        console.log(string);
    }
    func();
</script>


Output:

GEEKSFORGEEKS

Example 2:

JavaScript




<script>
    // JavaScript to illustrate .toUpperCase() 
      
    function func() {
          
        // Original string
        var str = 'It iS a Great Day.';
          
        // String converted to Upper Case
        var string = str.toUpperCase();
        console.log(string);
    }
      
    func();
</script>


Output:

IT IS A GREAT DAY.

Example 3: In this example, the method toUpperCase() converts all the lower case alphabets to their upper case equivalents without affecting the special characters and the digits. 

JavaScript




<script>
    // JavaScript to illustrate .toUpperCase() 
    function func() {
          
        //Original string
        var str = 'It iS a 5r&:ampe@@t Day.'
          
        //String converted to Upper Case
        var string = str.toUpperCase();
        console.log(string);
    }
      
    func();
</script>


Output:

IT IS A 5R&:AMPE@@T DAY.

We have a complete list of Javascript string methods, to check those please go through this Javascript String Complete reference article.

Supported Browser:

  • Chrome 1 and above
  • Edge 12 and above
  • Firefox 1 and above
  • Internet Explorer 3 and above
  • Opera 3 and above
  • Safari 1 and above

JavaScript is best known for web page development but it is also used in a variety of non-browser environments. You can learn JavaScript from the ground up by following this JavaScript


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!