Debugging Custom Blocks

In casual conversations, we sometimes trip on a word or say not quite what we mean. The other person usually understands anyway, and may not even notice the slip. Computers are not yet that smart! In programming, whatever we say—even if it's not what we meant—the computer tries to do. If it can't, it might report an error, or it might just give a wrong answer. Programmers call errors in their code "bugs," parts of the program that don't do what the programmer intended or that cause some other part of the program not to behave as intended. The process of finding and fixing bugs is called "debugging."

  1. spell (have a good day!) was intended to spell its input like this Spell(Have-a-good-day).

    But it doesn't work quite right. Here is its definition.

    Buggy Spell
    1. What does it do instead?
    2. Talk with Your Partner How can you fix the script?
  2. This script was designed to reset the stage when the user presses "c".
    1. When does it not work?
    2. Talk with Your Partner How can you fix the script?
  3. This script was intended to draw this squiral.
    buggy squiral script IntendedSquiral
    1. What does it do instead?
    2. Talk with Your Partner How can you fix the script?
Tough Stuff
  1. This script was designed to move the sprite to the right until it reaches x = 175.
    RepeatUntil x position = 175 (move 1 steps)
    1. It works, but it's slow. To fix it, we tried move 5 steps. That worked, too, but was too fast. So we tried move 2 steps, but then it never stopped! Why?
    2. Talk with Your Partner How can you fix the script so that it stops at the right place even when the "speed" is move 2 steps?
  2. The block below was intended to spell its input backward, like this Spell-Backward(New-York) when Spell backward (New York) is clicked.
    Buggy Backward
    1. What does it do instead?
    2. Talk with Your Partner How can you fix the script?