Programming concepts और सीखने के लिए आप
MDN Web Docs देख सकते हैं।
Example: 5 rows
Example: 5 rows के लिए
2. Pyramid Pattern
Pyramid pattern prints stars in the shape of a pyramid.
Pyramid pattern stars को pyramid shape में print करता है।
Use nested loops: outer for rows, inner for spaces and stars.
Increase stars by 2 in each row.
Center align using spaces.
Nested loops use करें: outer row, inner spaces और stars।
हर row में stars 2 से बढ़ाएं।
Spaces से center align करें।
Diagram
Example: 5 rows
Example: 5 rows के लिए
3. Number Pyramid
A pyramid pattern printing numbers increasing from left to right.
Number pyramid pattern left से right बढ़ते numbers print करता है।
Outer loop for rows.
Inner loop prints numbers sequentially.
Use spaces for alignment.
Outer loop rows के लिए।
Inner loop sequential numbers print करे।
Alignment के लिए spaces use करें।
Diagram
Example: 5 rows
Example: 5 rows के लिए
4. Inverted Pyramid
Inverted pyramid prints stars in decreasing order to form an inverted shape.
Inverted pyramid stars decreasing order में print करता है।
Outer loop for rows.
Inner loop prints spaces and stars.
Decrease stars by 2 each row.
Outer loop rows के लिए।
Inner loop spaces और stars print करे।
हर row में stars 2 से decrease।
Diagram
Example: 5 rows
Example: 5 rows के लिए
5. Diamond Star Pattern
Diamond pattern combines pyramid and inverted pyramid.
Diamond pattern pyramid और inverted pyramid को combine करता है।
Use two loops: one for top pyramid, one for bottom inverted pyramid.
Adjust spaces and stars for symmetry.
दो loops use करें: top pyramid और bottom inverted pyramid के लिए।
Spaces और stars symmetry के लिए adjust करें।
Diagram
Example: 5 rows top pyramid
Example: 5 rows top pyramid
6. Number Pyramid
Let's print a centered number pyramid (1, 121, 12321, ...). This pattern helps you practice nested loops and see how numbers and spacing work together to create neat shapes. Change the `rows` variable to try different sizes.
चलो एक centered number pyramid बनाते हैं (1, 121, 12321 ...). यह pattern nested loops और spacing को समझने में मदद करता है। अलग size try करने के लिए `rows` वाली value बदल दें।
Choose how many rows you want (variable `rows`).
For each row: first print leading spaces to center the pattern.
Then print ascending numbers from 1 up to the row number.
Then print descending numbers from row-1 back to 1 to make a palindrome.
Print each row with one console.log so it appears line-by-line in the output box.
सबसे पहले rows की संख्या तय करें (`rows` variable)।
हर row के लिए पहले leading spaces print करें ताकि pattern center हो।
फिर 1 से लेकर current row तक ascending numbers print करें।
उसके बाद row-1 से 1 तक descending numbers print करें ताकि palindrome बने।
हर row को एकल console.log में print करें ताकि output में सही line-by-line दिखे।
Diagram: Centered Number Pyramid
Example for rows = 5: outputs
1
121
12321
1234321
123454321
rows = 5 के लिए output:
1
121
12321
1234321
123454321
7. Floyd’s Triangle
Floyd's Triangle prints numbers in a continuous sequence in triangle shape.
Floyd's Triangle continuous sequence में numbers triangle shape में print करता है।
Use a counter starting from 1.
Outer loop for rows.
Inner loop prints numbers and increments counter.
1 से counter शुरू करें।
Outer loop rows के लिए।
Inner loop numbers print करे और counter बढ़ाए।
Diagram
Example: 5 rows
Example: 5 rows के लिए
8. Right Pascal’s Triangle
Right Pascal's Triangle is a combination of a normal and inverted right-angled triangle.
Right Pascal's Triangle normal और inverted right-angled triangle का combination है।
Print a right-angled triangle first.
Then print inverted right-angled triangle excluding the last row.
पहले right-angled triangle print करें।
फिर inverted triangle print करें, last row exclude करके।
Diagram
Example: 5 rows top triangle
Example: 5 rows top triangle
9. Pascal’s Triangle
Pascal's Triangle prints numbers where each number is the sum of the two numbers above it.
Pascal's Triangle में हर number ऊपर के दो numbers का sum होता है।
Start with 1 at the top.
Use nested loops to generate next row from previous row.
Use combination formula or iterative addition.
Top पर 1 से शुरू करें।
Nested loops से previous row से next row generate करें।
Combination formula या iterative addition use करें।
Diagram
Example: 5 rows
Example: 5 rows के लिए
10. Hollow Diamond Pattern
Hollow Diamond prints a diamond with empty space inside, using stars at borders.
Hollow Diamond border पर stars और अंदर empty space के साथ print करता है।
Use nested loops for top and bottom pyramid.
Print stars at first and last positions, spaces in between.