CodeAgeBy Sitezack
Final project: your TetrisTetris on Canvas, inside a real website0 XP
Chapter progress0/6

Lesson 2 of 6

The pieces

A piece is an object: its position (x, y) and its shape, a mini-grid of 0s and 1s. The O square is [[1, 1], [1, 1]].

makePiece() builds a FRESH piece on every call — every falling piece must be its own object.

function makePiece() {
  return {x: 4, y: 0, shape: [[1, 1], [1, 1]]};
}

🎯 Your goal

Write the makePiece() function that returns a new square piece: x is 4, y is 0, shape is [[1, 1], [1, 1]].

PRO lesson

This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.

Discover PRO