Now let's consider a slightly more complicated block that makes use of a loop.
It accepts two numbers as inputs (start
and end
)
and finds the sum of all of the numbers in the range from start
to end
, inclusive.
When start = 8
and end = 10
, the value reported by this function should be 27
(8+9+10).
However, the attempts at a solution shown below have some bugs. See if you can fix the bugs
in the code below so that each version reports the correct sum:
Note: click on any of the pictures to go to a Snap! file containing the code.