2
The data is arranged this way, but I want in the search field to insert an 'a', then only the fields containing letter 'a' appear. But if I put 'as' right away, the search should be updated. but it is cumulative. How to update?
let data = null;
request.onload = function() {
data = JSON.parse(this.response);
}
var filtro = document.getElementById('filtro-pesquisa');
filtro.onkeyup = function() {
var nomeFiltro = filtro.value;
data.results.forEach(x => {
if((x.name.first.toLowerCase().indexOf(nomeFiltro) >= 0) || (x.name.last.toLowerCase().indexOf(nomeFiltro) >= 0)){
buildCard(x.name, x.gender, x.picture, x.registered);
}
});
};