# How to lowercase or uppercase all array values in JavaScript

By Atta Ur Rehman Shah (https://attacomsian.com/about). Published May 26, 2020. Topics: JavaScript.
Canonical URL: https://attacomsian.com/blog/javascript-array-lowercase-uppercase

> A quick article to learn how to uppercase or lowercase all values in an array using JavaScript.

In JavaScript, you can use the [Array.map()](https://attacomsian.com/blog/javascript-array-map) method to iterate over all elements and then use the string methods to change the case of the elements.

Here is an example that demonstrates how to use the `String.toUpperCase()` method along with `Array.map()` to uppercase all elements in an array:

```javascript
const names = ['Ali', 'Atta', 'Alex', 'John'];

const uppercased = names.map(name => name.toUpperCase());

console.log(uppercased);

// ['ALI', 'ATTA', 'ALEX', 'JOHN']
```

The `toUpperCase()` method converts a [string to uppercase letters](https://attacomsian.com/blog/javascript-string-uppercase-lowercase) without changing the original string.

To convert all elements in an array to lowercase, you can use another JavaScript method called `String.toLowerCase()` as shown below:

```javascript
const names = ['Ali', 'Atta', 'Alex', 'John'];

const lowercased = names.map(name => name.toLowerCase());

console.log(lowercased);

// ['ali', 'atta', 'alex', 'john']
```

Both string methods work in all modern browsers, and IE6 and above. However, the `Array.map()` was introduced in ES6 and only supports IE9 and up. On the other hand, [arrow functions](https://attacomsian.com/blog/javascript-arrow-functions) do not work in IE at all. 

To support legacy browsers (IE9 and above), you should use the normal function instead:

```javascript
const uppercased = names.map(function (name) {
    return name.toUpperCase();
});

const lowercased = names.map(function (name) {
    return name.toLowerCase();
});
```

To learn more about JavaScript arrays and how to use them to store multiple pieces of information in one single variable, take a look at [this guide](https://attacomsian.com/blog/javascript-arrays).
