Home Basics Convert a string to upper case or lower case

Convert a string to upper case or lower case

The toUpperCase() method returns the value of the string converted to uppercase. This method does not affect the value of the string itself since JavaScript strings are immutable.

Example

 

var str = "This is A Test StriNG!"; 
var result = str.toUpperCase(); 
document.write(result);

which will display the following

THIS IS A TEST STRING!

The toLowerCase() method returns the value of the string converted to lower case. This method does not affect the value of the string str itself since JavaScript strings are immutable.

Example

 

var str = "This is A TEST STRING!";
var result = str.toLowerCase();
document.write(result);

which will display the following

this is a test string!

You may also like