After retrieving values from a database, I am using them in JSON/javascript as an array. For example, see
https://i.sstatic.net/nLzk9.png
The issue arises when trying to calculate the sum of the array elements.
I attempted to solve it with this code:
var obj1 = JSON.parse(data);
var mar = obj1.march;
var quantite = obj1.quant;
const sum = quantite.reduce((result,number)=> result+number);
console.log(sum);
Here is the output I received in the console
https://i.sstatic.net/klBh4.png
I am still learning about JSON and javascript, so any guidance or assistance would be greatly appreciated!