Jeeped
0
Q:

map()

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]
16
array.map((item) => {
  return item * 2
} // an example that will map through a a list of items and return a new array with the item multiplied by 2
21
The map() method creates a new array populated with the results of calling 
a provided function on every element in the calling array.

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]
2
const sweetArray = [2, 3, 4, 5, 35]
const sweeterArray = sweetArray.map(sweetItem => {
    return sweetItem * 2
})

console.log(sweeterArray)
3
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]
12
const map = new Map();

function foo() {
 return "Hello World!"; 
}

map.set("foo", foo);

console.log(map.get("foo")()); // Output: "Hello World!
3

array.map(function(currentValue, index, arr), thisValue)
7

  var numbers = [4, 9, 16, 25];
var x = numbers.map(Math.sqrt)

  document.getElementById("demo").innerHTML = x; 
3
const array1 = [1, 4, 9, 16];

var map1 = array1.map(x => x * 2);
var map2 = array1.map( function( x, i ) {
  	console.log(x, i);
  	// x = 1 , 4 , 9 ,16 i = 0 , 1 , 2 , 3
    return x
} ); 
console.log(map1);
// expected output: Array [2, 8, 18, 32]
3
['elem', 'another', 'name'].map((value, index, originalArray) => { 
  console.log(.....)
});
2

New to Communities?

Join the community