Tutorialspoint.dev

JavaScript | String toLowerCase()

str.toLowerCase() function converts the entire string to lower case. This function does not affect any of the special characters, digits and the alphabets that are already in the lower case.

Syntax:
str.toLowerCase()

Arguments
This function does not take any arguments.

Return value
This function returns a new string in which all the upper case letters are converted to lower case.

Examples for the above function are provided below:

Example 1:



var str = 'It iS a Great Day.';
var string = str.toLowerCase();
print(string);

Output:

it is a great day.

In this example, the function toLowerCase() converts all the upper case alphabets into lower case alphabets without affecting the special characters, digits and all those characters that are already in the lower case.

Example 2:

var str = 'It iS a 5r&[email protected]@t Day.';
var string = str.toLowerCase();
print(string);

Output:

it is a 5r&[email protected]@t day.

In this example the function toLowerCase() converts all the upper case alphabets into lower case alphabets without affecting the special characters, digits and all those characters that are already in lower case.

Codes for the above function are provided below:

Program 1:

<script>
// JavaScript Program to illustrate
//  toLowerCase() function
  
function func() {
     
    // Original string
    var str = 'It iS a Great Day.';
     
    // Converting to lower case
    var string = str.toLowerCase();
    document.write(string);
}
  
func();
</script>

Output:

it is a great day.

Program 2:

<script>
// JavaScript Program to illustrate
//  toLowerCase() function
  
function func() {
     
    //Original string
    var str = 'It iS a 5r&[email protected]@t Day.';
     
    //Converting to lower case
    var string = str.toLowerCase();
    document.write(string);
}
  
func();
</script>

Output:

it is a 5r&[email protected]@t day.


This article is attributed to GeeksforGeeks.org

You Might Also Like

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter