I have a json and I need to be able to count how many true there is, since it says if a patient is interned or not.
{
"pacientes" : [
{
"nroPaciente": 2,
"nombre": "Anakin Skywalker",
"edad": 50,
"internado": true
},
{
"nroPaciente": 1,
"nombre": "Emanuel Fernandez",
"edad": 16,
"internado": false
},
{
"nroPaciente": 3,
"nombre": "Julieta Otoño",
"edad": 32,
"internado": false
}
]
}
I got here by showing it by console, but I need to paint it on the screen in a number and not with Boolean values
function cantidadInter(){
fetch('./pacientes.json')
.then(res => res.json())
.then(data => {
let filtro= data.pacientes.filter(elemento => elemento.internado === true);
//console.log(filtro);
// console.log(filtro);
for(let i of filtro){
console.log(i.internado);
}
});
}