JavaScript - toUpperCase() method

revision:


Category : string

The toUpperCase() method converts a string to uppercase letters. The toUpperCase() method does not change the original string.

Syntax :

        string.toUpperCase()  
    

Parameters: none

Examples:

            <p>toUpperCase() converts a string to lowercase letters:</p>
            <p id="demo"></p>
            <script>
                let text = "Hello World!";
                let result = text.toUpperCase();
                document.getElementById("demo").innerHTML = result;
            </script>
        

Practical examples

example: convert to uppercase

code:
                    <div>
                        <p id="local-1"></p>
                        <p id="local-2"></p>
                    </div>
                    <script>
                    let text = "Hello World!";
                    document.getElementById("local-1").innerHTML = "text : " + text;
                    let result = text.toUpperCase();
                    document.getElementById("local-2").innerHTML = "text to uppercase : " + result;
            
                    </script>