How to Convert a JavaScript Array of Strings to Lowercase?

In JavaScript, you can make all strings in an array of strings lowercase by calling the String.prototype.toLowerCase() method on every element of the array using, for example, like so:

// ES6+
const arr = ['FOO', 'Bar', 'bAz'];
const newArr = => str.toLowerCase());

console.log(newArr); // ['foo', 'bar', 'baz']

You can rewrite the callback to without arrow function to make it compatible with ES5.

The code above would create a new array with all strings in the array in lowercase. You can achieve the same with a simple for loop as well:

const arr = ['FOO', 'Bar', 'bAz'];
const newArr = [];

for (let i = 0; i < arr.length; i++) {

console.log(newArr); // ['foo', 'bar', 'baz']

Hope you found this post useful. It was published . Please show your love and support by sharing this post.