How to 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.

let str = ' THIS SENTENCE SHOULD BE CONVERTED TO LOWERCASE';
let lowerCase = str.toLowerCase();
console.log(lowerCase);
let str = 'This sentence should be converted to UPPERCASE.';
let upperCase = str.toUpperCase();
console.log(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