I think Arnav_Pandey’s code is a good alternative doing the same thing as the default code and it’s working for me.
For this particular case you can even replace:
@alexbrand - I’m also not a programmer, a little bit of C, Pascal and Java once upon a time at the university. I’m only helping my son and even I don’t try completing levels that are too hard to explain to a child. You have posted some pieces of code that were inspirational for me and you are some of the few good coders that haven’t escaped codecombat and this forum.