-1
I have to generate a table with the first five colors stored in a json object. I believe I have many ways to do this, but what I have achieved so far is to filter the colors by level and by user:
let users = [{
"id": 1,
"username": "Gustavo",
"pwd": "20",
"scores": [{
"id": 2,
"score": 5,
"level": "hard"
},
{
"id": 3,
"score": 10,
"level": "easy"
},
{
"id": 4,
"score": 15,
"level": "easy"
}
]
},
{
"id": 2,
"username": "Elisa",
"pwd": "10",
"scores": [{
"id": 5,
"score": 150,
"level": "easy"
}]
},
{
"id": 3,
"username": "Tati",
"pwd": "2",
"scores": [{
"id": 5,
"score": 20,
"level": "easy"
},
{
"id": 5,
"score": 2,
"level": "easy"
},
{
"id": 5,
"score": 10,
"level": "easy"
}
]
}
]
`$ranking = users.map(users => ({ users: users.username, scores: users.scores.filter(scores => scores.level === "easy") }));`
Sorry for the insensitivity, but exactly what’s the problem?
– Augusto Vasques
So, I don’t know how to present the result in the table (the dynamic table I can assemble), but I can’t put the name and the score, so I said in the question that you can have a more direct way of doing, without having to save the name and the score in an array to then sort, and then show it on the chart. Do this filter I got, I do not know if it is possible to see this in the image I put, only appear the names and the object "Scores" with only the values whose level is "easy", but how to list this is that I can not..
– GUSTAVO LUIZ DUTRA SANTOS