Skip to content

Commit d8f19fd

Browse files
committed
feat: add additional loop constructs to control flow exercises
- Introduced `do...while`, `for...in`, `for...of`, and `for...await...of` loop examples in the README. - Enhanced the control flow section to provide comprehensive coverage of loop types in JavaScript.
1 parent af0f134 commit d8f19fd

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

exercises/04.control-flow/README.mdx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,38 @@ while (condition) {
7373
}
7474
```
7575

76+
**`do...while` loop** - When you want to run the code at least once:
77+
78+
```ts
79+
do {
80+
// Keep going until condition is false
81+
} while (condition)
82+
```
83+
84+
**`for...in` loop** - When you want to iterate over the properties of an object:
85+
86+
```ts
87+
for (const key in object) {
88+
// Keep going until condition is false
89+
}
90+
```
91+
92+
**`for...of` loop** - When you want to iterate over the values of an iterable:
93+
94+
```ts
95+
for (const value of iterable) {
96+
// Keep going until condition is false
97+
}
98+
```
99+
100+
**`for...await...of` loop** - When you want to iterate over the values of an async iterable:
101+
102+
```ts
103+
for await (const value of asyncIterable) {
104+
// Keep going until condition is false
105+
}
106+
```
107+
76108
## Ternary Operator
77109

78110
The ternary operator is a concise way to choose between two values:

0 commit comments

Comments
 (0)