0
Q:

map object

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
let map = new Map()
map['bla'] = 'blaa'
map['bla2'] = 'blaaa2'

console.log(map)  // Map { bla: 'blaa', bla2: 'blaaa2' }
2
let utilisateurs = new Map()

utilisateurs.set('Mark Zuckerberg' ,{
    email: '[email protected]',
    poste: 'PDG',
})

utilisateurs.set ('bill Gates',{
    email: '[email protected]' ,
    poste : 'sauver le monde' ,

})
    
console.log(utilisateurs);
0
The map() method creates a new array with the results of calling a provided function on every element in the calling array.
4
const objectMap = (obj, fn) =>
  Object.fromEntries(
    Object.entries(obj).map(
      ([k, v], i) => [k, fn(v, k, i)]
    )
  )
  
const myObject = { a: 1, b: 2, c: 3 }

console.log(objectMap(myObject, v => 2 * v)) 
-2
const objectMap = (obj, fn) =>
  Object.fromEntries(
    Object.entries(obj).map(
      ([k, v], i) => [k, fn(v, k, i)]
    )
  )
  
const myObject = { a: 1, b: 2, c: 3 }

console.log(objectMap(myObject, v => 2 * v));
-1

New to Communities?

Join the community