I need to show an object with the existing attribute list and showing a number of how many times it appears:
Payload:
[
[
"valor"
],
[
"tipo de entrada",
"data entrada",
"valor"
],
[
"tipo de entrada",
"data entrada",
"valor"
],
[
"tipo de entrada"
],
[
"tipo de entrada"
],
[
"tipo de entrada"
],
[
"valor"
],
[
"valor"
],
[
"valor"
],
[
"valor"
],
[
"tipo de entrada",
"data entrada",
"valor"
]
]
Result:
{
valor: 16,
tipo_entrada: 9,
dqta_entrada: 6
}
being that list of attributes dynamically, it can contain other values (value, name, age ...)
You can flatten your array using
array#flat()and then usingarray#reducecount the frequency of each word.