Better ways to modify string with multiple methods using JavaScript

JavascriptWeb DevelopmentObject Oriented Programming

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 −


var sentence = "tHIS iS tHE JavaScript pROGRAM";
function modifyStringWithMultipleMethods(sentence) {
   return sentence.charAt(0).toUpperCase() +

To run the above program, you need to use the following command −

node fileName.js.

Here, my file name is demo51.js.


This will produce the following output −

PS C:\Users\Amit\JavaScript-code> node demo51.js
This is the JavaScript program
Updated on 03-Sep-2020 06:37:11