I have an object, which I need to add up to a number of times words appear. Ex:
{
step1: ["luiz"]
step2: ["pedro"]
step3: ["luiz"]
step4: ["luiz"]
step5: ["luiz"]
}
I tried using .map, .forEach, .filter, but they all come back undefined.
.filter
let irmas = answers.filter((answer) => answer[1] === 'luiz)
.map
let contagemRespostas = answers.map(function(answer, index) {
return contagemRespostas.index
})
How do I get names only and add values?
EDIT:
The return is something like:
{ 'luiz': 3, 'pedro': 2 }
or the highest value { 'luiz': 3 }