-2

How to do i get the id value and brandName value

[{"id":24,"brandName":"BMW"},{"id":25,"brandName":"Mercedes Benz"}]
Chris Li
  • 2,628
  • 1
  • 8
  • 23
p.maimba
  • 33
  • 8

1 Answers1

0

Not sure what you're trying to do as your question is very vague. But if you want to iterate over each element and do something with the values you could do something like this:

let items = [{"id":24,"brandName":"BMW"},{"id":25,"brandName":"Mercedes Benz"}];

items.forEach(elem => {
    const {id, brandName} = elem;
    console.log(`ID: ${id}. Brand Name: ${brandName}.`);
})
Adam
  • 1,724
  • 13
  • 16