In addition to what is said, I would suggest that you consider if you want only one “highestNum”. I’m not saying that you need more than one variable, just that you may not want to use that one state for all the numbers. Is that what you are supposed to be checking? You might also want to think about where you are doing your push.
Not knowing where to define or return variable is a recurring issue for me.
Yeah, that is a common problem. It just takes practice.
Is there a way to use stepper for debugging?
Absolutely. I just think that log statements are easier for beginners. But if you feel comfortable with setting break points and stepping through your code, then go for it.
You insert log statements wherever you want to know what is going on.
A big part of being a good developer is being a good debugger. And a lot of being a debugger is being a detective. You have to investigate. Just start logging out information and seeing if it matches what you expect it to be. If you log it out and it matches your expectation, move forward and find where it stops. If it doesn’t match your expectations, more backwards and find where it stopped. Try it with different data to see how it handles different conditions.