[
{'id': 123, 'name': 'apples', 'total': 30},
{'id': 541, 'name': 'oranges', 'total': 42},
{'id': 300, 'name': 'bananas', 'total': 18}
]
How can I display the contents of this array in the following format:
Apples: 30
Oranges: 42
Bananas: 18
I attempted
let myArray = [{
'id': 123,
'name': 'apples',
'total': 30
},
{
'id': 541,
'name': 'oranges',
'total': 42
},
{
'id': 300,
'name': 'bananas',
'total': 18
}
]
console.log(JSON.stringify(myArray.map(a => a.name)))
however, this is not what I intended to achieve.