The JSON array
The array looks like this.
const oStock = [ { 'company': 'Google', 'price': 1296.25, 'change': '+2.1' }, { 'company': 'Cisco', 'price': 47.29, 'change': '-0.29' }, { 'company': 'SBI', 'price': 399.00, 'change': '+5.85' } ];
I want to get only the company and price property values from the array, ignoring the change property value.
Here’s the script.
<script> const oStock = [ { 'company': 'Google', 'price': 1296.25, 'change': '+2.1' }, { 'company': 'Cisco', 'price': 47.29, 'change': '-0.29' }, { 'company': 'SBI', 'price': 399.12, 'change': '+5.85' } ]; const arr = oStock.map(stock => ' ' + stock.company + ' <b>' + stock.price + '</b>'); document.getElementById('result').innerHTML = arr; </script>