1

Hello I have this code using React.js :

const array1 = [1, 4];

const map1 = array1.map(x =>{'x2': x * 2, 'x3': x * 3});

console.log(map1);
// expected output: Array [{'x2': , 1, 'x3': 1}, {'x2': 8, 'x3': 24}]

But it does not work ... could you help me please ?

Peter
  • 51
  • 2

1 Answers1

0

You have missing parentheses around your object:

const map1 = array1.map(x => ({ 'x2': x * 2, 'x3': x * 3 }));
Zsolt Meszaros
  • 21,961
  • 19
  • 54
  • 57