Answers for "map in an array"

23

array map javascript

const array1 = [1, 4, 9, 16];

// pass a function to map
const map1 = array1.map(x => x * 2);

console.log(map1);
// expected output: Array [2, 8, 18, 32]
Posted by: Guest on November-25-2019
0

map in an array

let numbers = [33, 22, 44, 55, 66, 77, 88, 99];
const getNumbers = numbers.map(number => number * 2);
console.log(getNumbers);
//Expected output:
/*[
    66,  44,  88, 110,
   132, 154, 176, 198
 ]
 */
Posted by: Guest on September-11-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language