JavaScript | String toUpperCase()
str.toUpperCase() function converts the entire string to Upper case. This function does not affect any of the special characters, digits and the alphabets that are already in upper case.
Syntax: str.toUpperCase()
Arguments
This function does not take any arguments.
Return value
This function returns a new string in which all the lower case letters are converted to upper case.
Examples for the above function 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 function 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 function toUpperCase() converts all the lower case alphabets to their upper case equivalents without affecting the special characters and the digits.
Codes for the above function 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:
- JavaScript | Check if a string is a valid JSON string
- JavaScript | Difference between String.slice and String.substring
- JavaScript | Insert a string at position X of another string
- How to count string occurrence in string using JavaScript?
- JavaScript | string.replace()
- JavaScript | string.toString()
- JavaScript | string.substring()
- JavaScript | String.fromCharCode()
- How to get the last character of a string in JavaScript?
- JavaScript | string.search()
- How to get nth occurrence of a string in JavaScript ?
- JavaScript | string.normalize()
- Reverse a String in JavaScript
- JavaScript to keep only first N characters in a string
- JavaScript | String trim()
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.



