I am working with firebase and react native.
I have returned an array from my firebase database that looks like this.
[Object, Object,
Use Array.prototype.forEach() method to iterate over your array and sum your elements.
Let us suppose your array is var foo = [object, object, object]
Each object
has this structure, { level : 4 }
Write code like this:
var sum = 0;
foo.forEach(function(obj){
sum += obj.level;
});
sum
will store the sum