In the following code below from the Cleanup Karel example, what is the purpose of If Statement #2?
// This program has Karel walk down the
// row and clean up all of the tennis balls
// on the way.
function start() {
while (frontIsClear()) {
// If statement #1
if (ballsPresent()) {
takeBall();
}
move();
}
// If statement #2
if (ballsPresent()) {
takeBall();
}
}
JavaScript
To move the last time
To pick up the ball that is in the last spot
To pick up the ball that is in the last spot, if there is one
To take the ball from all of the positions that have a ball on them