My array:
const a = [
{
"baseFare": "1439.00",
},
{
"baseFare": "1739.00",
},
{
"baseFare": "1039.00",
},
]
Note: The number of values in const a will increase or decrease its user decisions ! there may be one or 5 or 7 values in the array !
How to sum all the values and output a single value , and in somecase if its only one value then the out put should be direct single value !
How to achive this ?
My code :
a.reduce((a, b) => a + b, 0)