what is Array.map() code example
Example 1: how to use the map method in javascript
const numbers = [1, 2, 3, 4, 5];
const bigNumbers = numbers.map(number => {
return number * 10;
});
Example 2: array map
let numbers = [1, 4, 9]
let roots = numbers.map(function(num) {
return Math.sqrt(num)
})
// roots is now [1, 2, 3]
// numbers is still [1, 4, 9]