-2
I needed to know how many agencies I have in my json file and their respective numbers, in case I know they are 4, but the return being given is an array of 120 accounts only, and I would like an array with the 4 agencies, if anyone can help.
const ordenaAgencia=async()=>{
const data = await getData();
return await data.sort((item1, item2)=>item1.agencia-item2.agencia)
};
const maiorCadaAgencia=(dados)=>{
const agencias = [];
for(var i=0; i<dados.length; i++){
if(i == 0){
if(dados[i] != dados[i+1]){
agencias.push(dados[i].agencia)
}
} else if(dados[i] != dados[i-1]){
agencias.push(dados[i].agencia)
}
}
console.info(agencias)
}
ordenaAgencia().then(dados=>{
maiorCadaAgencia(dados)
});
Forget about guys, I think I just found the shit I did, I forgot to compare the agencies and I was just comparing the data
– Rai
You can post the answer to your question, so you can help others who have been through the same problem.
– Danizavtz