Skip to content

Commit 5d6b89f

Browse files
authored
Merge pull request #12 from kennarddh/feat/RightTriangleStarPattern
0007 RightTriangleStarPattern ( L-B )
2 parents c842933 + 4ae104f commit 5d6b89f

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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)

0 commit comments

Comments
 (0)