-2
<td>
   {{tickets.forEach((element) => element.ticketCategories.price))}}
</td>

tickets = [
  {
    ticketCategories: {
      type: 'Presale 1 Ticket',
      price: 75000,
    },
    sumTicket: 3,
  },
];

let result = tickets.map(({ticketCategories}) =>  ticketCategories.price)

console.log(result); // output: [75000]

how to get 75000 not [75000]

let result = tickets.map(({ticketCategories}) =>  ticketCategories.price)

console.log(ressult); // output: [75000]

i try use map but i get [75000] not 75000

jabaa
  • 5,844
  • 3
  • 9
  • 30
  • 1
    Do you want only the first element? The problem is unclear. `tickets` is an array and the expected result is one number. What's the expected result when `tickets` contains multiple elements? – jabaa Jan 26 '23 at 12:30
  • `ticketCategories` (plural) is a misnomer for an object representing a single category. – jarmod Jan 26 '23 at 12:33

1 Answers1

0

The map function returns an array. you can use forEach to log out each element of the result array or use join to join all the result elements to one string.

result.forEach(res => console.log(res))

console.log(result.join(", "))
Simcha
  • 36
  • 3