0

How can I limit this MAP, so that I only search the first 3 items, cleanly?

const Xx = actives.map(it => ({
    x: it.ticker,
    y: it.percent,
    label: it.percentual,
}));
blurfus
  • 13,485
  • 8
  • 55
  • 61

1 Answers1

0
const arr = [{id: 1}, {id: 2}, {id: 3}, {id: 4}];

const Xx = arr.slice(0, 3).map(el => ({
  x: el.id,
}));

console.log(Xx)
Mustafa Omar
  • 399
  • 4
  • 15