Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
No estoy seguro de por qué este código no funciona. El programa debe buscar a través de esta lista de palabras y eliminar cualquier palabra que incluya la letra A.

Esto se está haciendo en code.org, por alguna razón elimina algunas palabras con la letra A pero no todas, no estoy seguro de por qué no funcionará.

 var wordList = ["abase", "abate", "abbey", "abbot", "abhor", "abide", "abled", "abode", "abort", "about", "above", "abuse", "abyss", "acorn", "acrid", "actor", "acute", "adage", "adapt", "adept", "admin", "admit", "adobe", "adopt", "adore", "adorn", "adult", "affix", "afire", "afoot", "afoul", "after", "bulge", "bulky", "bully", "bunch", "bunny", "burly", "burnt", "burst", "bused", "bushy", "butch", "butte", "buxom", "buyer", "bylaw", "cabal", "cabby", "cabin", "cable", "cacao", "cache", "cacti", "pique", "setup", "seven", "sever", "wrote", "wrung", "wryly", "yacht", "yearn", "yeast", "yield", "young", "youth", "zebra", "zesty", "zonal"]; var wrongLettersList = ["a"]; var unsureLettersList = []; var goodLettersList = []; onEvent("wrongLetterInput", "input", function( ) { appendItem(wrongLettersList, getText("wrongLetterInput")); setProperty("wrongLetterInput","text", ""); setProperty("wrongLetterInput", "placeholder", "Letters inputted: "+wrongLettersList); listFilter(wrongLettersList, unsureLettersList, goodLettersList); }); function listFilter(wrongLetters, unsureLetters, goodLetters) { for(var j = 0; j<wordList.length; j++) { if(wordList[j].includes(wrongLetters[0])){ wordList.splice(j, 1); } } console.log(wordList); }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Eso es porque te saltas una palabra una vez que empalmas. La opción fácil, pero no la mejor, es:

 function listFilter(wrongLetters, unsureLetters, goodLetters) { for(var j = 0; j<wordList.length; j++) { if(wordList[j].includes(wrongLetters[0])){ wordList.splice(j, 1); j-=1; // ---> decrement 1 from j so you don't skip a word } } console.log(wordList); }

Pero definitivamente, como se dijo anteriormente, usar el filtro es mucho más fácil y legible.

 return wordList.filter(w => !w.includes(wrongLettersList[0]));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda