Need some help with a infinite loop

I’m making a spelling game and trying to check the word for correctness.

when breaking down the correct spelling and incorrect spelling of the word with GetCharacterArrayFromString GetCharacterArrayFromString
With a for each loop

On number one there is an infinite loop happening. I’m comparing two arrays and if there is a letter missing (like a hole in the array for the incorrect array)

on the right, the E at index 1 is missing from the incorrect array, on the left, and that throws off the array. So I made some logic for when a letter is missed insert an array index at that index. but only if the array’s length on tested word instance array is less than incorrect character array It works at first but if you input 1 letter or 2 it puts you into an infinite loop. Any suggestions?

Another problem, second box.

Setting the colors doesn’t do what is set. When it’s true the color looks like its faded, and when false it’s back instead of red

Stepping through the debugger it sets the red color so little confused
word

Why don’t you start comparing when the player finishes entering the word, it will be more efficient and you wouldn’t need an infinite loop.

I’m doing that already I don’t want an infinite loop that’s the problem. it starts at the top box on that branch. let’s say I get MOM as my test word. I input a G instead of MOM

  1. the first branch, when the tested word instance M == G Fails it tries the second branch this is where it gets stuck since that this evaluation is always true it never reaches the false block.

Sorry to ask, but why are you checking the lengths of the string array?

Dis morning I realized I didn’t need that check at all. Pretty noob programmer here under a year lol. Anyways I solved my problem

2 Likes