Within my code I have an embedded if statement which uses the else, however on the first if statement whenever I use else again for the highest if statement it just causes an error and I'm not sure why. Here is my code:
01 | if challengeLength > enteredLength then |
02 | if challengeString = = enteredText then |
03 | print ( "CORRECT" ) |
04 | else |
05 | enteredLength = enteredLength - 1 |
06 | print ( "Incorrect" ) |
07 | else -- This is the else that it causes an error on |
08 | print ( "Done" ) |
09 | end |
10 | end |
You put the end's in the wrong position, here is it fixed:
01 | if challengeLength > enteredLength then |
02 | if challengeString = = enteredText then |
03 | print ( "CORRECT" ) |
04 | else |
05 | enteredLength = enteredLength - 1 |
06 | print ( "Incorrect" ) |
07 | end --Correct placement of the end. |
08 | else |
09 | print ( "Done" ) |
10 | end |