Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

185
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda