Way to get the sum property values of an object

I'd like to get the sum of object properties

Here is my Input

{
    "Obj1": {
        "1": 50,
        "2": 45.5,
        "3": 15,
        "4": 10,
        "5": 20
    },   
    "Obj2": {
        "1": 12.5,
        "2": 0,
        "3": 0,
        "4": 12.5,
        "5": 0
    }
}

Want my output to be

Obj1 = 140.5          
Obj2 = 25

Let me know if there is a way to get the output as mentioned above in javascript

Thanks in advance!!!



Read more here: https://stackoverflow.com/questions/68473615/way-to-get-the-sum-property-values-of-an-object

Content Attribution

This content was originally published by manju k at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: