Please someone explain to me why this is not working correctly.
So I have a random word in an array (word_store). This array contains a word with e.g. 5 letters. The max length of the word is 16 so I have randomly generated 11 more letters in the array so it’s full.
In the code below I pick one letter from the word_store at random then I need to find the matching letter within another array as this calls an object to be drawn. This is what is returned from the function.
The problem is that whenever one of the random letters are picked these are matched and returned fine, but with any of the other letters from the original word no letters are matched. I have checked each element in the array and there are no spaces before or after these letters so they aren’t trying to match a letter and a space.
The problem is strictly with the matching. I’m running out of ideas so does anyone know what’s up?
Thanks
function pick_letter_from_array(): String {
var random_position_in_word = Random.Range(0,word_store.length);
var board_letter = word_store[random_position_in_word];
print ("random letter: " + board_letter);
//use letter to set the texture and the cube position
for (var i=0; i<setupGame.letters.length; i++){
if (board_letter == setupGame.letters*){*
_ print ("we have a match: " + setupGame.letters*);_
word_store.RemoveAt(random_position_in_word);
return_letter = setupGame.letters;
_ }
else{
print (setupGame.letters + “: no match”);
}
}_
return return_letter;
_}*_