To modify string, you can use toLowerCase() as well as toUpperCase(). Let’s say the following is our string −
var sentence = "tHIS iS tHE JavaScript pROGRAM";
To modify and display in proper case, the code is as follows −
Example
var sentence = "tHIS iS tHE JavaScript pROGRAM"; function modifyStringWithMultipleMethods(sentence) { return sentence.charAt(0).toUpperCase() + sentence.slice(1).toLowerCase(); } console.log(modifyStringWithMultipleMethods(sentence));
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo51.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo51.js This is the JavaScript program