If you’re working through the CodeHS JavaScript or Graphics unit, you’ve probably hit 3.5.5: Hexagon . At first glance, it seems simple: just draw a six-sided polygon. But getting the angles right and placing it correctly on the screen can be tricky.
After 6 iterations, the turtle has turned 6 × 60° = 360° , returning to its original heading. The shape closes perfectly. ❌ Using right(120) or left(120) ✅ Use left(60) – the exterior angle. 3.5.5 hexagon codehs
function start() var hex = new Turtle(); hex.penUp(); hex.goTo(100, 200); // Adjust starting position hex.penDown(); drawHexagon(hex, 50); // Side length = 50 If you’re working through the CodeHS JavaScript or
| Step | Action | Angle turned | |------|--------|--------------| | 1 | Forward (side length) | — | | 2 | Left 60° | 60 | | 3 | Repeat 6 times | — | After 6 iterations, the turtle has turned 6
hex.beginPath(); for(var i = 0; i < 6; i++) hex.forward(50); hex.left(60);