OneBite.Dev - Coding blog in a bite size

convert a string to lowercase in Javascript

Code snippet on how to convert a string to lowercase in Javascript

const s = 'This Is a String';
let lowercase = s.toLowerCase();

This code snippet uses the toLowerCase() method to convert a string to all lowercase letters. The string we are using is “This Is a String”, and we store it in a variable called s. Then, we create a new variable called lowercase to store the result of our toLowerCase() method. Lastly, we call the toLowerCase() method on our variable s, and the result is stored in our lowercase variable. This method takes all of the letters in the string and changes them to all lowercase letters, so the output is “this is a string”.

javascript