I want to remove elements from an array only if exist empty elements in another array. I have this:
var fruits = ["Banana", "Naranja", "Manzana", "Mango", "Fresa", "Limón", "Lima", "Sandia"];
var vegetales = ["", "Ajo", "", "Cebolla", "Tomate", "", "", "Zanahoria"];
    
// The output should be this:
// ["Naranja", "Mango", "Fresa", "Sandia"]
function myFunction() {
  for (var i in vegetales) {
    if (vegetales[i] == '') {
      frutaAeliminar = fruits[i];
      indexFruta = fruits.indexOf(frutaAeliminar);
      if (indexFruta != -1) {
        fruits.splice(indexFruta, 1)
      }
    }
  }
  console.log(fruits);
}
myFunction();




