File tree Expand file tree Collapse file tree 2 files changed +79
-0
lines changed
L-B/0007 RightTriangleStarPattern ( L-B ) Expand file tree Collapse file tree 2 files changed +79
-0
lines changed Original file line number Diff line number Diff line change 1+ # 0007 RightTriangleStarPattern ( L-B )
2+
3+ ## Problem
4+
5+ Create a function that accept size parameter in number and log right triangle star pattern.
6+
7+ ### Example
8+
9+ #### Size 5
10+
11+ ```
12+ *
13+ **
14+ ***
15+ ****
16+ *****
17+ ```
18+
19+ #### Size 4
20+
21+ ```
22+ *
23+ **
24+ ***
25+ ****
26+ ```
27+
28+ #### Size 3
29+
30+ ```
31+ *
32+ **
33+ ***
34+ ```
35+
36+ ## Solution
37+
38+ ``` javascript
39+ const RightTriangleStarPattern = size => {
40+ for (let y = 0 ; y < size; y++ ) {
41+ let temp = ' '
42+
43+ for (let x = 0 ; x <= y; x++ ) {
44+ temp += ' *'
45+ }
46+
47+ console .log (temp)
48+ }
49+ }
50+ ```
51+
52+ ## References
53+
54+ - [ For Loop MDN] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for )
55+ - [ Loop MDN] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration )
56+ - [ Nested Loop FreeCodeCamp] ( https://www.freecodecamp.org/news/nesting-for-loops-in-javascript/ )
57+
58+ ## Problem Added By
59+
60+ - [ GitHub] ( https://www.github.com/kennarddh )
61+
62+ ## Contributing
63+
64+ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
65+
66+ Please make sure to update tests as appropriate.
Original file line number Diff line number Diff line change 1+ const RightTriangleStarPattern = ( size ) => {
2+ for ( let y = 0 ; y < size ; y ++ ) {
3+ let temp = ''
4+
5+ for ( let x = 0 ; x <= y ; x ++ ) {
6+ temp += '*'
7+ }
8+
9+ console . log ( temp )
10+ }
11+ }
12+
13+ RightTriangleStarPattern ( 5 )
You can’t perform that action at this time.
0 commit comments