it's me again, now with reactjs.
I have a json, inside it have two "rows", they are Description
and ubication
. I need to filter the array by Description
.
How can I filter this? The description it's in text format for example "Impact"
or "Wiu wiu"
.
I know the function filter()
of typescript have a numeric condition but no have a text condition or I haven't seen it been use for that.
Thank you so much for your help.
No still you can do with Text as well,
let filtered = yourArray.filter(t=>t.Description ==='impact');
DEMO
let mydata = {
"ArrayBotones": [
{
"descripcion": "Impacto",
"ubicacion": "sonidos/impacto.mp3"
},
{
"descripcion": "Soy Fede",
"ubicacion": "sonidos/holasoyfede.wav"
},
{
"descripcion": "Wiu wiu",
"ubicacion": "sonidos/wiuwiu.wav"
},
{
"descripcion": "3 carajos",
"ubicacion": "sonidos/3carajos.wav"
},
{
"descripcion": "Apurate Jose",
"ubicacion": "sonidos/apuratejose.wav"
},
{
"descripcion": "No, no se",
"ubicacion": "sonidos/nonose.wav"
}
]
};
let result = mydata.ArrayBotones.filter(t=>t.descripcion === 'Impacto');
console.log(result);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With