Wednesday, February 04, 2015 Repeat Until Loop

The repeat until code block
The “repeat until” block gave many of the students a challenge last week. Just looking at the block it is easy to see how they were confused. We will be using puzzle 15 of 20 in this example of the “repeat until” block located at
Here the steps in the repeat block are repeated until you get to the sunflower. Here is what is what is happening in the repeat until block above:
  1. Did you get the sunflower?
    1. If not, move forward a step and go to number 2 below.
    2. If yes, then you are finished so get out of the "repeat block" and eat that sunflower!
  2. Is there a path to the right of me?
    1. If yes, turn right.
  3. Go back to number 1 and "repeat" the steps.
1. Chris Bosh, NBA star of the Miami Heat, explains this code block at

The above section can be used as a handout to the class.

When a student successfully runs puzzle 15 and they select the Show Code button in the popup, here is the code that is displayed:

Here is a section from some JavaScript code that I created to simulate the repeat block:

Here is how that would look for each step on the maze: