In JavaScript, you can use the 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 to uppercase all elements in an array:

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

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


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

The toUpperCase() method converts a string to uppercase letters 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:

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

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


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

Both string methods work in all modern browsers, and IE6 and above. However, the was introduced in ES6 and only supports IE9 and up. On the other hand, arrow functions do not work in IE at all.

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

const uppercased = (name) {
    return name.toUpperCase();

const lowercased = (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.

✌️ Like this article? Follow me on Twitter and LinkedIn. You can also Subscribe to RSS Feed.

Last Updated: