I need to make addition using NodeJS in an array JSON and then return the altered JSON like this, I need also check if key exist or not to avoid exceptions:
JSON:
{
    "cmd": [
        {
            "sales": [
                {
                    "qte1": "2",
                    "qte2": "3", 
                    "someString": "test 
                },
                {
                    "qte1": "66",
                    "someAttribute": "test " 
                },
                {
                    "qte2": "77",
                    "toto": "tata"
                }
            ]
        }
    ]
} 
target JSON:
{
    "cmd": [
        {
            "sales": [
                {
                    "qte1": "2",
                    "qte2": "3",
                    "somme": "5"
                },
                {
                    "qte1": "66",
                    "somme": "66"
                },
                {
                    "qte2": "77",
                    "somme": "77"
                }
            ]
        }
    ]
}
I need to add the two key qte1 et qte2 would you have any propositions ?
Best regards
 
     
     
    