Force String to Lower or Upper Case

JavaScript has built in methods to manipulate strings making this task easy. You can call the toLowerCase() or toUpperCase() on the string directly.

Make a string lower case.

var str = "Hello World!";
var lowerCaseStr = str.toLowerCase();
console.log(lowerCaseStr);

Make a string upper case.

var str = "Hello World!";
var upperCaseStr = str.toUpperCase();
console.log(upperCaseStr);

Leave a Reply

Your email address will not be published.