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); }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]));