Day 13 – Print Downward Right-Aligned Star Triangle in JavaScript ⭐📐

Опубликовано: 21 Май 2026
на канале: Code with Poonam
89
7

Welcome to Day 13 of the 30 Days of Pattern Hack Challenge! 🚀
Today’s challenge is all about creating a right-aligned triangle using stars (*) — a classic exercise to strengthen your grasp of nested loops, conditional logic, and string manipulation in JavaScript!

⭐ Pattern Output for n = 4:
****
***
**
*

💡 Approach:
✅ Define a function printPattern(n)
✅ Use nested loops:
  • Outer loop for rows (from n to 1)
  • Inner loop (j) for columns (from 1 to n)
✅ For each cell:
  • Add" " (space)
  • Else, add a "*" (star)
✅ After each row, add \n to move to the next line

📚 Key Concepts Covered:
Pattern construction using nested loops
Right-alignment using conditional space-padding
String building with newline characters
Loop control for reverse sequencing

💬 Try it with different values of n and observe how the alignment and shape change!
These foundational patterns sharpen your thinking for more advanced layout logic and algorithmic design. Keep building — your logic muscle is growing! 💪✨

#JavaScript #PatternHack #30DayChallenge #NestedLoops #PatternPrinting #100DaysOfCode #CodeNewbie #ProgrammingIsFun #JavaScriptForBeginners #WebDevJourney #LogicalThinking #ProblemSolving #FrontendDev #LearnToCode #RightAlignedPatterns #PatternPrintingInJS #TechChallenge #JSBasics #CodingDaily #KeepCoding