Playing with the Console Log

To display the browser console in popular web browsers, several methods are available. In Google Chrome, press Ctrl + Shift + J (Windows/Linux) or Cmd + Option + J (Mac) to open the console directly, or use the menu by clicking the three-dot icon in the top-right corner, selecting "More Tools," then "Developer Tools," and navigating to the Console tab.

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);

// To display the browser console in popular web browsers, 
// several methods are available. In Google Chrome, 
// press Ctrl + Shift + J (Windows/Linux) or 
// Cmd + Option + J (Mac) to open the console directly,
// or use the menu by clicking the three-dot icon in the top-
// right corner, selecting "More Tools," then 
// "Developer Tools," and navigating to the Console tab.


// Global code will be evaluated once.
const turtle = new Turtle();
turtle.penup();
turtle.goto(-50,-20);
turtle.pendown();

// The walk function will be called until it returns false.
function walk(i) {
    turtle.forward(100);
    turtle.right(144);
    console.log("Helo World " + i); // send a message to the browser console
    return i < 4;

}