The map() method is called as a prototype method of an array. The function passed to array.map() runs on every element in that array, and then returns a new array with the returned values.
The following examples convert distance, temperature, weight, and time to demonstrate some scenarios for when and how to use the Array.map() method.
- Convert Meters to Centimeters
- Convert Celsius to Fahrenheit
- Convert Kilograms to Grams
- Convert Years to Days
Let’s say we have an array of measurements in meters, but what we really need is an array of those measurements in centimeters. To convert from Meters to Centimeters multiply total meters by 100