Open In App

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

Last Updated : 09 Jan, 2023
Like Article

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. 



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.



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


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads