0
I have a json that has names of equal people, and I need to count how many names are repeated and give a total sum. I did it one way, but he’s counting the number of characters in the name and not counting the total number of equal names.
{
"candidates": [
{
"CLIENT_ID": "Dread Pirate Alannah Company",
"VALUE": 0,
"LOST_VALUE": 45,
},
{
"CLIENT_ID": "Dread Pirate Alannah Company",
"VALUE": 56.25,
"LOST_VALUE": 0,
},
{
"CLIENT_ID": "Dread Pirate Alannah Company",
"VALUE": 45,
"LOST_VALUE": 0,
},
{
"CLIENT_ID": "Wis Company",
"VALUE": 45,
"LOST_VALUE": 0,
}
]
}
Code that I applied
function allRejected(arr){
var contador = 0;
if (arr !== undefined){
for (var item = 0; item < arr.length; item++){
if (item !== undefined && arr.indexOf(item)){
contador ++;
}
}
}
return contador;
}
@Why Andrémartins? What’s wrong with him?
– Costamilam
I was wrong were 2 in the morning rsrs @Costamilam
– André Martins