Friday, September 5, 2025
HomeLanguagesJavascriptWhich built-in method returns the calling string value converted to upper case...

Which built-in method returns the calling string value converted to upper case in JavaScript ?

The toUpperCase() built-in method returns the calling string value converted to uppercase in the javascript. This method does not affect any of the special characters, digits, and alphabets that are already in the upper case. 

Syntax:

String.prototype.toUpperCase()

Approach: This is a simple HTML file. In the body, there are two p tags one with id text in which some content is written and then there is a button with which a function is associated and it will be called on event onclick with the mouse. Inside the script tag, there is some js code, in the first line we are extracting the string from the p tag with id ‘text’ and later inside the function clickHandler() which will eventually be called when someone will click on the associated button. This function contains a call to the toUpperCase() method by the string named myString. In the end, we are simply putting the result into the p tag with id text.

Example:

HTML




<p>
    The text written below will be converted
    to Upper Case after clicking on Button
</p>
 
<p id="text">Hello, neveropen Learner!!</p>
 
<button onclick="clickHandler()">
    Click Here
</button>
 
<script>
    let myString = document.getElementById("text").innerHTML;
     
    const clickHandler = () => {
        let result = myString.toUpperCase();
        document.getElementById("text").innerHTML = result;
    }
</script>


Output:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11861 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS