
By using toLocaleUpperCase()
we can convert the string to uppercase letters.
<p>Click the below button to Convert.</p> <input type="button" value="Convert" onclick="Function()" /> <p id="myId"></p> <script> function Function() { var A = "techfunda"; var r = A.toLocaleUpperCase(); document.getElementById("myId").innerHTML = r; } </script>
In the above code snippet we have given Id
to the second <p>
element in the HTML code, there is a string in lowercase letters with variable A in the<script>
code. We need to convert the lowercase letters in a string to the uppercase letters, for that we use string method toLocaleUpperCase()
. Onclick of the button "Convert" fires the Function() in the <script>
code at the same time toLocaleUpperCase()
method converts the lowercase letters to the uppercase letters and gives the output.
OUTPUT