If you want to convert all the letters in a string to lowercase, then use the toLowerCase()
method. It is important to note that the toLowerCase() method does not modify the original string and returns a new string having all characters in lowercase.
The syntax for the toLowerCase()
method is:
let lowerCaseString = string.toLowerCase();
The following example converts all the characters in a string to lowercase:
let str = "JavaScript String"; let newString = str.toLowerCase(); console.log(newString); //javascript string console.log(str); //JavaScript String