Category: Turtle
Rotates the turtle left by the specified angle. The turtle’s position remains the same.
turnLeft() is one of the ways to change the turtle's orientation. When used with moveForward(), you can move, and draw with, the turtle anywhere on the screen.
// Rotate the turtle left 90 degrees (the default angle) from the current direction. turnLeft();
Example: Square Draw a square with left turns only.
// Draw a square with left turns only. moveForward(); turnLeft(); moveForward(); turnLeft(); moveForward(); turnLeft(); moveForward(); turnLeft();
Example: Checkmark Draw a checkmark with left turns using angle parameters.
// Draw a checkmark with left turns using angle parameters. turnLeft(120); moveForward(100); turnLeft(270); moveForward(25);
Example: House Draw a house with left turns only.
// Draw a house with left turns only. turnLeft(45); moveForward(50); turnLeft(90); moveForward(50); turnLeft(45); moveForward(75); turnLeft(-270); // same as turnLeft(90); moveForward(70); turnLeft(90); moveForward(75); |
turnLeft(angle)
Name | Type | Required? | Description |
---|---|---|---|
angle | number | No | The angle to rotate left (90 degrees is default). |
No return value. Rotates turtle only.
Found a bug in the documentation? Let us know at documentation@code.org
Found a bug in the documentation? Let us know at documentation@code.org