const originalArray = ['BMW', 'AUDI', 'MERCEDEZ', 'JAGUAR']; const lowercaseArray = originalArray.map(item => item.toLowerCase()); console.log(lowercaseArray);
[ 'bmw', 'audi', 'mercedez', 'jaguar' ]
In this code, we have an array called originalArray that contains strings in uppercase.
In the next step, we used the “map()” method to iterate through each array element and applied the “toLowerCase()” method to convert each string to lowercase.
The result is a new array called lowercaseArray containing the lowercase versions of the original strings.
We used an “arrow function” to simplify the callback function passed to the “map()” method. The result is the same as in the previous example.
Niva Shah is a Software Engineer with over eight years of experience. She has developed a strong foundation in computer science principles and a passion for problem-solving.