Sunday, 1 February 2026

Code Solutions

/* Students programs may vary, but
 * here is one possible solution.
*/

function main() {
    // Move Karel at 9 times
    for (let i = 0; i < 9; i++) {
        walk();
    }
}

// This function paints the river orange, or moves forward
function walk() {
    if (colorIs(Color.cyan)) {
        paint(Color.orange);
        move();
    } else {
        move();   
    }
}

main();

No comments:

Post a Comment