Unfortunately, a Wordle Project I happen to have been creating has a slight bug or possible error which I am not quite sure how to address: for every correct (green/accepted) letter, it repeats it as a yellow letter (a letter present within the word but is incorrectly placed) if the user types a word which repeats the correct letter again even if such letter is only present ONCE within the word.
(The correct word is SOAPY, meaning only one “O” is present throughout the entire code.)
Ex: SOUND has O in the correct place.
SOOTH has O in the correct place and the next following O turns yellow.
SOAPY is the correct word!
(**In case you need a little more context: Wordle is a game where the user is provided with six different word guesses to decipher a correct 5-letter word. My variation is called “Swordle”, where a specific pool of 5-letter words that begin with “S” are provided for to be the hidden word.
Gray means that the letter is not present whatsoever, yellow means the letter is present within the word but in the wrong place (like if SOUND was the word but you typed SLOWS; the “O” is present but in the wrong place.), and green equates to a correctly positioned letter present within a word.)
So far, I have tried defining a separate array to hold the values of each letter and to double-check that they are not repeated before running the rest of the process (i.e. the flipping animation, color coding each letter). That too seemed to not fully repair the issue, so can any superior coder break it down better, and possibly even provide a quick and effective solution? Thanks!
1