Below is the example of the String toUpperCase() Method.
- Example:
<script>functionfunc() {varstr ='geeksforgeeks';varstring = str.toUpperCase();document.write(string);}func();</script>chevron_rightfilter_none - Output:
GEEKSFORGEEKS
str.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 lower case letters are converted to upper case.
Examples for the above method are provided below:
Example 1:
var str = 'It iS a Great Day.'; var string = str.toUpperCase(); print(string);
Output:
IT IS A GREAT DAY.
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.
Example 2:
var str = 'It iS a 5r&e@@t Day.' var string = str.toUpperCase(); print(string);
Output:
IT IS A 5R&E@@T DAY.
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.
Codes for the above method are provided below:
Program 1:
<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(); document.write(string); } func(); </script> |
Output:
IT IS A GREAT DAY.
Program 2:
<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(); document.write(string); } func(); </script> |
Output:
IT IS A 5R&:AMPE@@T DAY.
Recommended Posts:
- TypeScript | String toUpperCase() Method
- How to count string occurrence in string using JavaScript?
- JavaScript | Difference between String.slice and String.substring
- JavaScript | Check if a string is a valid JSON string
- JavaScript | Insert a string at position X of another string
- JavaScript String startsWith() Method
- JavaScript String toLowerCase() Method
- JavaScript String split() Method
- JavaScript String indexOf() Method
- JavaScript String endsWith() Method
- JavaScript String concat() Method
- JavaScript String.fromCharCode() Method
- JavaScript String trim() Method
- JavaScript String substr() Method
- JavaScript String.prototype.charCodeAt() Method
- JavaScript String includes() Method
- JavaScript string.toString() Method
- JavaScript string.codePointAt() Method
- JavaScript String.fromCodePoint() Method
- JavaScript string.localeCompare() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


