JSFiddle - React, Tailwind, and code Playground

by derykroot

HTML

<!DOCTYPE html>
<html>
<body>

<h2>Jogadores</h2>

<p id="demo"></p>

</body>
</html>

JavaScript

const jogadores = [
	{nome: "Neymar", ativo: true},
	{nome: "Cafu", ativo: false},
	{nome: "Kaká", ativo: false},
	{nome: "Paquetá", ativo: true},
	{nome: "Richarlison", ativo: true}];
              
// Remover jogadores fora da Ativa
function removeRecursive(items){
  var idx = items.findIndex(reg => !reg.ativo);
  if (idx>-1) {
    items.splice(idx,1);
    removeRecursive(items);
  }
}

removeRecursive(jogadores);
document.getElementById("demo").innerHTML = jogadores.map( j => j.nome);
console.log(jogadores)