Pick a pattern. Get the loops in and pseudocode.
38 figures, from first-year classics to advanced shapes. Change the size and the character, watch the pattern print row by row, then copy the code.
pattern.js
Pyramid
1
const n = 5;2
3
for (let i = 1; i <= n; i++) {4
let row = "";5
for (let s = 1; s <= n - i; s++) {6
row += " ";7
}8
for (let j = 1; j <= 2 * i - 1; j++) {9
row += "*";10
}11
console.log(row);12
}01
Pick
Squares, rhombus, triangles, pyramids, diamonds and advanced shapes. Solid or hollow.
02
Tune
Set the size and the character. The output follows the slider.
03
Copy
Watch the loops run row by row, then copy the code.
Gallery
Every classic, and a few surprises.
01Squares
Square
02Squares
Hollow Square
03Rhombus
Rhombus
04Rhombus
Hollow Rhombus
05Rhombus
Mirrored Rhombus
06Rhombus
Mirrored Hollow Rhombus
07Triangles
Left Triangle
08Triangles
Hollow Left Triangle
09Triangles
Right Triangle
10Triangles
Hollow Right Triangle
11Triangles
Inverted Left Triangle
12Triangles
Hollow Inverted Left Triangle
13Triangles
Inverted Right Triangle
14Triangles
Hollow Inverted Right Triangle
15Pyramids
Pyramid
16Pyramids
Hollow Pyramid
17Pyramids
Inverted Pyramid
18Pyramids
Inverted Hollow Pyramid
19Diamonds
Half Diamond (Right Pascal)
20Diamonds
Half Diamond (Left Pascal)
21Diamonds
Diamond
22Diamonds
Hollow Diamond
23Diamonds
Hourglass
24Advanced
Butterfly
25Advanced
Hollow Butterfly
26Advanced
X Pattern
27Advanced
Plus Sign
28Advanced
Checkerboard
29Advanced
Hollow Hourglass
30Advanced
Hexagon
31Advanced
Hollow Hexagon
32Advanced
Up Arrow
33Advanced
Christmas Tree
34Advanced
Diamond in Square
35Advanced
Square with Cross
36Advanced
Z Pattern
37Advanced
N Pattern
38Advanced