Quantcast
Channel: Answers by "Kleptomaniac"
Viewing all articles
Browse latest Browse all 90

Answer by Kleptomaniac

$
0
0
I would suggest cleaning this up. As @IgnoranceIsBliss said, strings can already be accessed as arrays. Therefore you can eliminate your SplitString function. Also, I'm assuming that underScore is the inputted letter? If so, your if statement would only return true if both indexes lined up in each array and were equal to each other. For example, if `underScore = "a"`, and `splitWord = "banana"`, checking for whether `underScore[i] == splitWord[i]` would not work because the index of "a" in underScore is 0 while the only a's in splitWord are 1, 3, and 5. Therefore, you need to check if the element in splitWord is equal to underScore as a whole string. So like this: function CheckIfCorrect() { for(i = 0; i < splitWord.Length; i++) { if(splitWord[i] == underScore) { Debug.Log("Guessed Right"); } } listOfLetters.Clear(); } This returns "Guessed Right" for me. :) Also, just in case that doesn't work, ensure you're actually calling your function. However I doubt that will be a problem. :D Hope that helped, Klep

Viewing all articles
Browse latest Browse all 90

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>