i have this array:
var res =
[
{ '5': 0 }, { '23': 0 },
{ '74': 0 }, { '45': 0 },
{ '10': 0 }, { '46': 1 },
{ '33': 0 }, { '18': 0 },
{ '67': 1 }, { '28': 0 },
{ '68': 0 }, { '56': 0 },
{ '78': 0 }, { '71': 0 },
{ '50': 1 }, { '14': 0 },
{ '39': 0 }, { '91': 0 },
{ '37': 0 }, { '34': 0 }
];
I want to sum second values to get result. like in this example result must be 2. I am using nodejs, if it helps.
Thank you.
Object.values(obj)[0]will get you the "first" value in an object where "first" is in quotes because if there's more than one value, it's not clear what your algorithm wants to do.