Reset the game - clear screen


#1

I have a student whose clicker game stacks ice cream scoops. She went through and reset / hid all the elements when the game resets…this amounted into a lot of lines of code. We were wondering is there a more efficient command to reset all the elements at once instead of doing them individually?


#2

Perhaps… can you send me the share-able link? I will take a look at it!

KT


#3

@msibley ACTUALLY, it is a snow day here in Minneapolis, so I just tested it out myself you can find the actual app that I used to test it out here. You can re-mix it yourself too.

The short answer is, yes, with clever id names, you can loop through all the elements that you want to show/hide. SO, student were introduced to loops in unit 3, but the actual mechanics of for loops aren’t really explored until lesson 15.

Also, in the Color Sleuth App (lesson 10) they use the same clever naming scheme to pick a random button.

It sounds like this student is super motivated though! There are some quick videos at the beginning of lesson 15 that explain for loops in more detail. It might be worth having her peek at those and see if she can figure it out herself. BUT I love the fact that she is thinking like a programmer (“There MUST be a better way to do this…”) AND it could be a great teachable moment to talk about iterative and incremental development. Going back and “refactoring” your code is an EXCELLENT example of iterative development!

Let me know if you have any more questions!

Happy programming!
KT