This function is
toLowerCase() and it don't take any parameters. One particularity is that it will not update your string but return an updated version.
Let me show you a quick example with an uppercase string.
const lastName = 'THOMAS' // Convert the uppercase string to lowercase console.log(lastName.toLowerCase()) // Output: "thomas"
As mentioned previously, this function will not modify the original string. If you want to save your lower case result, you'll need to create a new variable.
Here's how you can do it!
const lastName = 'ThOmAs' const lowerCaseLastName = lastName.toLowerCase() console.log(lastName) // Output: "ThOmAs" console.log(lowerCaseLastName) // Output: "thomas"
As you can see, the first variable stays unchanged.
➡️ I'm starting to tweet more consistently. If you want to get more tips and resources about web development, developer tips, and my journey as a Full-stack Engineer -> Find me on my Twitter 🐦