Convert JavaScript String to be All Lowercase and Vice Versa

You can make a JavaScript string all lowercase and uppercase with two functions. The String.toLowerCase() converts a string to lowercase, and String.toUpperCase()converts a string to uppercase.

var str = 'This sentence should be converted to lowercase And UPPERCASE.';
var lowerCase = str.toLowerCase();
// returns 'This sentence should be converted to lowercase and uppercase.'
var upperCase = str.toUpperCase();
// returns 'THIS SENTENCE SHOULD BE CONVERTED TO LOWERCASE AND UPPERCASE.'

The toLowerCase() and toUpperCase() Functions

Javascript string toLowerCase() an inbuilt method returns the calling string value converted to lowercase. The toLowerCase() function does not affect the value of the string.

The string toUpperCase() returns the calling string value converted to uppercase. This function does not affect any of the special characters, digits, and the alphabets already in uppercase.


Do you find this helpful?

Related articles