How to usethe toLowerCase() Method in Javascript
This approach uses the built-in toLowerCase()
method of the string object to convert all characters in the string to lowercase.
Example: Here, the toLowerCase()
method is called on the originalString
variable, which contains the string “Hello World”. The result is stored in the lowercasedString
variable, and when logged to the console, it prints “hello world”.
Javascript
let originalString = "Hello World" ; let lowercasedString = originalString.toLowerCase(); console.log(lowercasedString); // Output: "hello world" |
Output
hello world
How to Lowercase a String in JavaScript ?
In JavaScript, converting a string to lowercase means transforming all the characters in the string to their lowercase equivalents. This operation is often used to ensure consistent comparison or formatting of text.
Below are the approaches used to Lowercase a string in JavaScript:
Table of Content
- Using the toLowerCase() Method
- Using a Custom Function with map() and toLowerCase()
- Using a Regular Expression