Solution: Going Loopy Over Arrays
Explore how to apply JavaScript array methods like map and filter to manipulate strings within arrays. Learn to convert array elements to uppercase using map and filter out elements based on character conditions, gaining hands-on skills for practical programming.
We'll cover the following...
We'll cover the following...
Solution 1
Here is a possible solution for the capitals function that uses the map to return a new array of the same words written in uppercase.
Explanation
Line 1: Declares a constant variable
arrand assign it an array containing five strings.Line 3–5: Defines a function called
capitalsthat takes an array as an argument. Inside the function:...