How to lowercase string - JavaScript

Mo Ibra

Mo Ibra

Jan 5, 2023

In this article we will learn how to lowercase a string in JavaScript.

It is very common to lowercase a string in JavaScript in JavaScript.


Problem

Now we have a problem which is that we want to lowercase a string.

Now let's imagine that we have an string like this:

"HELLO WORLD!"

And want to lowercase this string to became like this:

"hello world!"

How to solve this problem?

The solution to this problem is easy, especially since there is a built-in function that does this called toLowerCase().


lowercase a string using toLowerCase

As we said before, we can use toLowerCase method to lowercase our string.

Let's see an example:

// String
const string = "HELLO WORLD!";

// lowercase your string
const lowercase = string.toLowerCase();

// Result:
console.log(lowercase);

Output

hello world!

Thank you for reading

Thank you for reading my blog. 🚀

Suggestions For More Articles: